Completed
Push — master ( 06c1ce...67d37c )
by Jeroen
06:20
created

Twig/PagesConfigurationTwigExtension.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\NodeBundle\Twig;
4
5
use Kunstmaan\NodeBundle\Entity\HasNodeInterface;
6
use Kunstmaan\NodeBundle\Helper\PagesConfiguration;
7
use Twig\Extension\AbstractExtension;
8
use Twig\TwigFunction;
9
10
/**
11
 * @final since 5.4
12
 */
13
class PagesConfigurationTwigExtension extends AbstractExtension
14
{
15
    /** @var PagesConfiguration */
16
    private $pagesConfiguration;
17
18
    /**
19
     * @param PagesConfiguration $pagesConfiguration
20
     */
21
    public function __construct(PagesConfiguration $pagesConfiguration)
22
    {
23
        $this->pagesConfiguration = $pagesConfiguration;
24
    }
25
26
    /**
27
     * Returns a list of functions to add to the existing list.
28
     *
29
     * @return array An array of functions
0 ignored issues
show
Consider making the return type a bit more specific; maybe use array<string,TwigFunction>.

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...
30
     */
31
    public function getFunctions()
32
    {
33
        return [
34
            'get_possible_child_types' => new TwigFunction(
35
                'get_possible_child_types', [$this, 'getPossibleChildTypes']
36
            ),
37
            'get_homepage_types' => new TwigFunction(
38
                'get_homepage_types', [$this, 'getHomepageTypes']
39
            ),
40
        ];
41
    }
42
43
    /**
44
     * @param string|HasNodeInterface $reference
45
     *
46
     * @return array
47
     */
48
    public function getPossibleChildTypes($reference)
49
    {
50
        return $this->pagesConfiguration->getPossibleChildTypes($reference);
51
    }
52
53
    /**
54
     * @return array
55
     */
56
    public function getHomepageTypes()
57
    {
58
        return $this->pagesConfiguration->getHomepageTypes();
59
    }
60
}
61