Completed
Pull Request — master (#48)
by Vladimir
03:17
created

FinderFunction::__invoke()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

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