Passed
Pull Request — master (#3)
by Stanislau
04:15 queued 01:16
created

ExtensionLoader::supports()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
rs 10
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