ExtensionLoader::provideExtensions()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 2
c 1
b 0
f 0
nc 2
nop 2
dl 0
loc 4
rs 10
ccs 3
cts 3
cp 1
crap 2
1
<?php
2
3
/*
4
 *  This file is part of the Micro framework package.
5
 *
6
 *  (c) Stanislau Komar <[email protected]>
7
 *
8
 *  For the full copyright and license information, please view the LICENSE
9
 *  file that was distributed with this source code.
10
 */
11
12
namespace Micro\Plugin\Twig\Business\Loader;
13
14
use Micro\Plugin\Twig\Plugin\TwigExtensionPluginInterface;
15
use Twig\Environment;
16
17
class ExtensionLoader implements LoaderInterface
18
{
19
    /**
20
     * {@inheritDoc}
21
     */
22 1
    public function load(Environment $environment, object $plugin): void
23
    {
24 1
        if (!$plugin instanceof TwigExtensionPluginInterface) {
25 1
            return;
26
        }
27
28 1
        $this->provideExtensions($environment, $plugin);
29
    }
30
31 1
    protected function provideExtensions(Environment $environment, TwigExtensionPluginInterface $extensionProvider): void
32
    {
33 1
        foreach ($extensionProvider->provideTwigExtensions() as $extension) {
34 1
            $environment->addExtension($extension);
35
        }
36
    }
37
}
38