Exemplo n.º 1
0
 /**
  * Return a slugged version of a string.
  *
  * @param string $string
  * @return string
  */
 public static function slugify($string)
 {
     $string = strip_tags($string);
     $string = str_replace(['&', '&'], 'and', $string);
     $string = str_replace('@', 'at', $string);
     // @codeCoverageIgnoreStart
     if (class_exists('Titon\\G11n\\Utility\\Inflector')) {
         return \Titon\G11n\Utility\Inflector::slug($string);
     }
     // @codeCoverageIgnoreEnd
     return Inflector::slug($string);
 }
Exemplo n.º 2
0
 function slug($string)
 {
     return Inflector::slug($string);
 }
Exemplo n.º 3
0
 /**
  * Test that strings are returned slugged.
  */
 public function testSlug()
 {
     $this->assertEquals('this-is-a-string-with-studly-case', Inflector::slug('This is A sTring wIth sTudly cAse'));
     $this->assertEquals('andthisonehasunderscores', Inflector::slug('and_this_ONE_has_underscores'));
     $this->assertEquals('while-this-one-contains-__-dashes', Inflector::slug('WHILE this one contains -- DASHES'));
     $this->assertEquals('thisis-amix-of-underscores-__-anddashes', Inflector::slug('This_is A_MIX oF undeRscores -- aNd_dashes'));
     $this->assertEquals('lastly-this-string-contains-punctuation', Inflector::slug('LaStlY, this STRING contains "punctuation"!'));
 }