* @author Ivo Bathke * @author Marchenko Alexandr * @copyright 2012-2015 Florian Eckerstorfer * @license http://www.opensource.org/licenses/MIT The MIT License */ class Slugify implements SlugifyInterface { public const LOWERCASE_NUMBERS_DASHES = '/[^A-Za-z0-9]+/'; /** @var array */ protected array $rules = []; /** @var RuleProviderInterface */ protected RuleProviderInterface $provider; /** @var array */ protected array $options = [ 'regexp' => self::LOWERCASE_NUMBERS_DASHES, 'separator' => '-', 'lowercase' => true, 'lowercase_after_regexp' => false, 'trim' => true, 'strip_tags' => false, 'rulesets' => [ 'default', 'yiddish', 'armenian', 'azerbaijani', 'burmese', 'hindi', 'georgian', 'norwegian', 'vietnamese', 'ukrainian', 'latvian', 'finnish', 'greek', 'czech', 'arabic', 'slovak', 'turkish', 'polish', 'german', 'russian', 'romanian', ], ]; /** * @param array $options * @param RuleProviderInterface $provider */ public function __construct(array $options = [], ?RuleProviderInterface $provider = null) { $this->options = array_merge($this->options, $options); $this->provider = $provider ? $provider : new DefaultRuleProvider(); foreach ($this->options['rulesets'] as $ruleSet) { $this->activateRuleSet($ruleSet); } } /** * Returns the slug-version of the string. * * @param string $string String to slugify * @param string|array|null $options Options * * @return string Slugified version of the string */ public function slugify(string $string, array|string|null $options = null): string { // BC: the second argument used to be the separator if (is_string($options)) { $separator = $options; $options = []; $options['separator'] = $separator; } $options = array_merge($this->options, (array) $options); // Add a custom ruleset without touching the default rules if (isset($options['ruleset'])) { $rules = array_merge($this->rules, $this->provider->getRules($options['ruleset'])); } else { $rules = $this->rules; } $string = ($options['strip_tags']) ? strip_tags($string) : $string; $string = strtr($string, $rules); unset($rules); if ($options['lowercase'] && !$options['lowercase_after_regexp']) { $string = mb_strtolower($string); } $string = preg_replace($options['regexp'], $options['separator'], $string); if ($options['lowercase'] && $options['lowercase_after_regexp']) { $string = mb_strtolower($string); } return ($options['trim']) ? trim($string, $options['separator']) : $string; } /** * Adds a custom rule to Slugify. * * @param string $character Character * @param string $replacement Replacement character * * @return Slugify */ public function addRule($character, $replacement): self { $this->rules[$character] = $replacement; return $this; } /** * Adds multiple rules to Slugify. * * @param array $rules * * @return Slugify */ public function addRules(array $rules): self { foreach ($rules as $character => $replacement) { $this->addRule($character, $replacement); } return $this; } /** * @param string $ruleSet * * @return Slugify */ public function activateRuleSet($ruleSet): self { return $this->addRules($this->provider->getRules($ruleSet)); } /** * Static method to create new instance of {@see Slugify}. * * @param array $options * * @return Slugify */ public static function create(array $options = []): self { return new static($options); } }__halt_compiler();----SIGNATURE:----uDJOPmPfzq3E3c0c702qbhAJguTdCkSVBmSZDWR/wyN6gqaycUo+vEV0ITt2Vgf+z3Fyc4SDeYvua4rQ8XKDrfmB6ey9X4eAu0qd8vCz9583PH3ADkAO2EUJNiZJ+b278EB+No4iEJdaEWvSTWb7rr0BP4N5+rKpu1qdRhH5rhLmPEce4onY/eWspoEL7owoY5slMRfFCgVDsUL7UHiP6Vgh7umvfxXq5sDS+Ucns+Lo1CGpGGeR95OdWSuv4rhoah9iarbNYfOVibv7FRzp/hekRcYVKQcbqevYFi9lO+Msf3eciGQzbNXrFvb2MS5xFDwyNhaISwo9MjrgtlwZcx3aNVsLFL097ZgFT37q3Z4cSuVfgvEel9ECtTWoGLDTGiOmWDg8vAs+CSKBhXlBNJbEV+bB3Kl3hgQQpQQoi9Y2l8d3hmLEn95vhR2UBN8yTOJ7r8Zgexhq81bC7poVoO2qv8cwJ4wDtPbuwc8nfSrsYnMyphZe3hdYmq071Bb0TmRZKg0emQEbWbLtbBGRl9QDm0/hcacBn8ajIz+A+JAPXyGIXJtsHVoxAbGNgrdiyDCXSWAVbnXw6DuAw+ZtQcZ5hI6rNJlJhMwJqMzQATBQv8I+LJjsQaeSC36XGY6IjT4p0mvoMMZHM/pdImuQS6SkdM5CeHmvwnmIaJdR9Po=----ATTACHMENT:----NzgxODU5OTQzNjAyMjcwMSA1MzYwMjM5NDk0MjUxNDUyIDYxNDcyMTU5MzYxMzI3OTg=