/**
  * Gets a builded slugifier to sanitize strings.
  *
  * @param boolean $renew whether to reload the slugifier.
  * @return Slugifier
  */
 protected static function getSlugifier($renew = false)
 {
     if (self::$_slugifier === null || $renew) {
         $factory = new RangeFactory();
         self::$_slugifier = new Slugifier();
         foreach ($factory->getRangesFromScript(RangeScript::ALL()) as $range) {
             self::$_slugifier->handleRange($range, true);
         }
         self::$_slugifier->setFlag(Flag::IGNORE_NONSTRINGS, true);
         self::$_slugifier->setFlag(Flag::IGNORE_NOTLOADED, true);
     }
     return self::$_slugifier;
 }
Beispiel #2
0
<?php

use Anastaszor\Slugify\Slugifier;
use Anastaszor\Slugify\RangeFactory;
use Anastaszor\Slugify\RangeScript;
echo "This is a test script to tests the slugification results of a given string.\n";
echo "Give a string :\n";
$input = fgets(STDIN);
echo "You gave : " . $input . "\n";
require __DIR__ . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php';
$slugifier = new Slugifier();
$factory = new RangeFactory();
foreach ($factory->getRangesFromScript(RangeScript::ALL()) as $range) {
    $slugifier->handleRange($range, true);
}
echo "Result: " . $slugifier->slugify($input);
echo "\n";
echo "Script ending.";