* @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:----Y9FBxplL1Mx7iCg26SVtgq2fSgHXx3hdcFkFSEGuvzXuir8l0cpKDhKiIfAdToLRT7QwUPnbVtDN6f2NWcHY2iS4pjDnKfZeZk+ijEHfe0qIor3DXQ7sm4tF8Vj3mi1qd2CgcwIgBepyXd6vo7YKGRfMRbxYjubXTO0+4efM22cmSBjmIBZKe+eVHIXIPgoJdP6xtpDtgJ+hXG0n56zm3mxRtU7iSbfmLbXL2GRNzVmXEqCzEEXJioKQ9QsB7jUbxKunOugpzNb2G0ULG9IbNYA3ZuIwL7AQVo9DxZ9qNtSgScQM+tPghe9oBxphB757vZNhEzhK07iWXS01XKk6NlZukLA2IIJGIkJeZSwPfRLj7tFZkGUiPreH+ILqI7cP2+zyzrGrZpS7CnACxWHQ+LSKIyFMHFRxWFsKTXLirIqhtvwyVFYY+JRB2Auzm88uQm4UvKqVW0WHsSA46N/6GO6bTmjUa3zGwwSIShTuRoQLy3BZG6s0aE8du8GFdbY/tuWwJLZKd13IoJIzZzSbYmoEUOImpXCkpfk9Ujfesxq2zgl2R6Njuko4oBKRh5pmdU273+f83lLx9tmxxpmB741gGzIiWhoFXV+7+Jd1qzv6FZhwBKqv32blbcbJ1Ev7Bj9+ycitTK4JT0py2JyBoePo8hfHlBWJLDhIfyYQJRs=----ATTACHMENT:----NDY1MjIxMzA4NDE3NTA4MSA1MzI1NDkyMzY0NDAwMTE2IDc2MTg1NDYxNzMzMjk3NTU=