addRules() public method

Adds multiple rules to Slugify.
public addRules ( array $rules ) : Slugify
$rules array
return Slugify
Esempio n. 1
0
 /**
  * @param $string
  * @return string
  */
 public static function genSlug($string)
 {
     //		return $string;
     //$accepted = implode(self::$MY_RULE);
     //$replace_char = "/([^a-zA-Z0-9" . $accepted . "]|-)+/u";
     //echo $replace_char;
     $slug_engine = new Slugify();
     //new Slugify($replace_char);
     $slug_engine->addRules(self::$MY_RULE);
     $slug_engine->addRule('#', '-sharp-');
     $slug_engine->addRule('+', '-plus-');
     return $slug_engine->slugify($string);
 }
 /**
  * @test
  * @covers Cocur\Slugify\Slugify::addRules()
  * @covers Cocur\Slugify\Slugify::slugify()
  */
 public function addRulesAddsMultipleRules()
 {
     $this->assertInstanceOf('Cocur\\Slugify\\Slugify', $this->slugify->addRules(['x' => 'y', 'a' => 'b']));
     $this->assertEquals('yb', $this->slugify->slugify('xa'));
 }
Esempio n. 3
0
 /**
  * Adds multiple rules to Slugify.
  *
  * @param \Cocur\Slugify\array<string,string> $rules
  * @return \Cocur\Slugify\Slugify 
  * @static 
  */
 public static function addRules($rules)
 {
     return \Cocur\Slugify\Slugify::addRules($rules);
 }