* @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', // Languages are preferred if they appear later, list is ordered by number of // websites in that language // https://en.wikipedia.org/wiki/Languages_used_on_the_Internet#Content_languages_for_websites '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 { 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:----cY8gVdDiFvbr0ceoy5zE+udSjG8tkQKSwDXoBH7zXm7i9rWLLRt5e+tjjzGlSsrm1iFaUt1KpxumDxoEbnWH/x2AypN9FSBzPtpEF+XzYJf/3AUhINb/wunEOAOQF5rnZz7eHa7BPc9SoGImQXBpf+5CK8Zc/ZgioAwVSzrseqOGVdo4dcnvpbjdqYohcxlcwYcAVOhoRQd7sq/zu7UxRh2Phi04VQ4QkPQGetr+40Co9zaGekfFAZf22p0rE3vMlK1vqTr3Xw0vF7uq8ZQngk2HUmlze8z0prcDhPlmhl0amPljdlK8zm7ZmangqMjc1R+CDnyu+mDGSU08ZO2e3DvVPc7GetV7xDszcO/vnNk/pYPVHdV7NzVLVuB+Qbyiq8dkJbJX7MhhOOGMqm2jYc/St+FkErprEDuXMTYq+z6KpVBTsezktGC2ePU6bh+ie+H3gVcgEjzMIJdopNyHbWBDk4v7xelNepPV51sFlKUqJAFoMDgtHncdgjOAev7IZDFC0T+5LdVow/6X2Z2jzH1wUgwjwBjlzt59uhTaqgoMhb3BKFuCEeioQ3xISNSJfnQztTFNxmiz/7rgPtFvh3yTp2hysc4POkzDs2g35S3WV8PZRMiAYhlxhoqWnu00hkja4gNib3vmw17XURsZdu82LtydRih+FX+dQ/eudII=----ATTACHMENT:----NTA3MTc0OTAxMTA1MzMyMiA3MDA4ODQzMTg2MjM4MzUzIDU3NDMzMjI0MDQ3MzYxMTE=