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

FinderFunction   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 0
Metric Value
wmc 3
c 0
b 0
f 0
lcom 0
cbo 4
dl 0
loc 24
rs 10

3 Methods

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