Completed
Push — master ( 3df90d...74371a )
by Vladimir
04:10
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 5
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 allejo\stakx\Filesystem\FilesystemLoader as fs;
11
use Symfony\Component\Finder\Finder;
12
use Twig_Environment;
13
14
class FinderFunction extends TwigFilesystem implements StakxTwigFunction
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 6
    public static function get()
27
    {
28 6
        return new \Twig_SimpleFunction('finder', new self(), array(
29 6
            'needs_environment' => true,
30 6
        ));
31
    }
32
}
33