ExtensionLoader   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 18
rs 10
ccs 7
cts 7
cp 1
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A load() 0 7 2
A provideExtensions() 0 4 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