Completed
Push — master ( 1de9b7...830752 )
by Kristof
38:46 queued 24:09
created

UtilitiesBundle/Twig/UtilitiesTwigExtension.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
namespace Kunstmaan\UtilitiesBundle\Twig;
4
5
use Kunstmaan\UtilitiesBundle\Helper\SlugifierInterface;
6
7
class UtilitiesTwigExtension extends \Twig_Extension
8
{
9
    /**
10
     * @var SlugifierInterface
11
     */
12
    private $slugifier;
13
14
    /**
15
     * @param $slugifier
16
     */
17
    public function __construct($slugifier)
18
    {
19
        $this->slugifier = $slugifier;
20
    }
21
22
    /**
23
     * Returns a list of filters.
24
     *
25
     * @return array An array of filters
0 ignored issues
show
Consider making the return type a bit more specific; maybe use \Twig_SimpleFilter[].

This check looks for the generic type array as a return type and suggests a more specific type. This type is inferred from the actual code.

Loading history...
26
     */
27
    public function getFilters()
28
    {
29
        return array(
30
            new \Twig_SimpleFilter('slugify', [$this, 'slugify']),
31
        );
32
    }
33
34
    /**
35
     * @param string $text
36
     *
37
     * @return string
38
     */
39
    public function slugify($text)
40
    {
41
        return $this->slugifier->slugify($text);
42
    }
43
}
44