Completed
Pull Request — 5.6 (#2830)
by Jeroen
14:14
created

UtilitiesBundle/Twig/UtilitiesTwigExtension.php (1 issue)

Checks whether return doc types can be made more specific.

Documentation Informational

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
use Twig\Extension\AbstractExtension;
7
use Twig\TwigFilter;
8
9
/**
10
 * @final since 5.4
11
 */
12
class UtilitiesTwigExtension extends AbstractExtension
13
{
14
    /**
15
     * @var SlugifierInterface
16
     */
17
    private $slugifier;
18
19
    /**
20
     * @param $slugifier
21
     */
22
    public function __construct($slugifier)
23
    {
24
        $this->slugifier = $slugifier;
25
    }
26
27
    /**
28
     * Returns a list of filters.
29
     *
30
     * @return array An array of filters
0 ignored issues
show
Consider making the return type a bit more specific; maybe use TwigFilter[].

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...
31
     */
32
    public function getFilters()
33
    {
34
        return [
35
            new TwigFilter('slugify', [$this, 'slugify']),
36
        ];
37
    }
38
39
    /**
40
     * @param string $text
41
     *
42
     * @return string
43
     */
44
    public function slugify($text)
45
    {
46
        return $this->slugifier->slugify($text);
47
    }
48
}
49