Completed
Push — master ( 02086d...3ba854 )
by Mike
03:44 queued 01:47
created

AtomExtension   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 11
dl 0
loc 34
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getFunctions() 0 11 1
A twigAtom() 0 3 1
1
<?php
2
declare(strict_types=1);
3
4
5
namespace Xervice\Atomic\Business\Twig\Extension;
6
7
8
class AtomExtension extends \Twig_Extension
9
{
10
    protected const FUNCTION_NAME = 'atom';
11
12
    protected const ATOM_MODULE = 'Atomic';
13
14
    /**
15
     * @return array|\Twig_Function[]
16
     */
17 1
    public function getFunctions(): array
18
    {
19
        return [
20 1
            new \Twig_SimpleFunction(
21 1
                self::FUNCTION_NAME,
22
                function (string $atomName, string $atomModule = self::ATOM_MODULE) {
23 1
                    return $this->twigAtom($atomName, $atomModule);
24 1
                },
25
                [
26 1
                    $this,
27 1
                    self::FUNCTION_NAME
28
                ]
29
            )
30
        ];
31
    }
32
33
    /**
34
     * @param $atomName
35
     * @param $atomModule
36
     *
37
     * @return string
38
     */
39 1
    private function twigAtom(string $atomName, string $atomModule): string
40
    {
41 1
        return '@' . $atomModule . '/atomic/atoms/' . $atomName . '/' . $atomName . '.twig';
42
    }
43
44
}