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

FinderFunction   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Test Coverage

Coverage 44.44%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 4
dl 0
loc 19
ccs 4
cts 9
cp 0.4444
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 9 1
A get() 0 6 1
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