Bolt\Twig\Handler\TextHandler::slug PHP Method

slug() public method

Return the 'sluggified' version of a string.
public slug ( string $str ) : string
$str string input value
return string Slug safe version of the string
    public function slug($str)
    {
        if (is_array($str)) {
            $str = implode(' ', $str);
        }
        return $this->app['slugify']->slugify($str);
    }

Usage Example

Beispiel #1
0
 public function testSlugArray()
 {
     $app = $this->getApp();
     $handler = new TextHandler($app);
     $slug = ['Köala & Clippy', 'úp thé trèé'];
     $result = $handler->slug($slug);
     $this->assertSame('koeala-clippy-up-the-tree', $result);
 }