TwigTemplatePluginTrait::getTwigTemplatePaths()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2.0116

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 6
c 1
b 0
f 1
nc 2
nop 0
dl 0
loc 11
cc 2
rs 10
ccs 6
cts 7
cp 0.8571
crap 2.0116
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 *  This file is part of the Micro framework package.
7
 *
8
 *  (c) Stanislau Komar <[email protected]>
9
 *
10
 *  For the full copyright and license information, please view the LICENSE
11
 *  file that was distributed with this source code.
12
 */
13
14
namespace Micro\Plugin\Twig\Plugin;
15
16
trait TwigTemplatePluginTrait
17
{
18
    /**
19
     * @return string[]
20
     */
21 2
    public function getTwigTemplatePaths(): array
22
    {
23 2
        $classCurrent = new \ReflectionObject($this);
24 2
        $filename = $classCurrent->getFileName();
25
26 2
        if (false === $filename) {
27
            throw new \RuntimeException('Unable to determine path from where to load twig templates.');
28
        }
29
30 2
        return [
31 2
            \dirname($filename).\DIRECTORY_SEPARATOR.'templates',
32 2
        ];
33
    }
34
35 2
    public function getTwigNamespace(): ?string
36
    {
37 2
        $classCurrent = new \ReflectionObject($this);
38 2
        if ($classCurrent->isAnonymous()) {
39 1
            return null;
40
        }
41
42 1
        return $classCurrent->getShortName();
43
    }
44
}
45