Completed
Push — master ( 74371a...6da8c0 )
by Vladimir
02:21
created

FinderFunction::__invoke()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 9
rs 9.6666
cc 1
eloc 5
nc 1
nop 2
1
<?php
2
3
/**
4
 * @copyright 2018 Vladimir Jimenez
5
 * @license   https://github.com/allejo/stakx/blob/master/LICENSE.md MIT
6
 */
7
8
namespace allejo\stakx\Templating\Twig\Extension;
9
10
use allejo\stakx\Filesystem\FilesystemLoader as fs;
11
use Symfony\Component\Finder\Finder;
12
use Twig_Environment;
13
14
class FinderFunction extends AbstractFilesystemTwigExtension implements TwigFunctionInterface
15
{
16
    public function __invoke(Twig_Environment $env, $folderLocation)
17
    {
18
        parent::__invoke($env, $folderLocation);
19
20
        $finder = new Finder();
21
        $finder->in(fs::absolutePath($folderLocation));
22
23
        return $finder;
24
    }
25
26
    public static function get()
27
    {
28
        return new \Twig_SimpleFunction('finder', new self(), array(
29
            'needs_environment' => true,
30
        ));
31
    }
32
33
    public static function disableInSafeMode()
34
    {
35
        return true;
36
    }
37
}
38