Completed
Push — master ( 3df90d...74371a )
by Vladimir
04:10
created

FinderFunction::get()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 6
ccs 4
cts 4
cp 1
crap 1
rs 9.4285
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