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

LoaderProcessor::process()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 4
c 1
b 0
f 0
nc 3
nop 2
dl 0
loc 8
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\Framework\Kernel\KernelInterface;
15
use Twig\Environment;
16
use Twig\Error\Error;
17
use Twig\Error\LoaderError;
18
19
readonly class LoaderProcessor implements LoaderProcessorInterface
0 ignored issues
show
Bug introduced by
A parse error occurred: Syntax error, unexpected T_READONLY on line 19 at column 0
Loading history...
20
{
21
    /**
22
     * @param LoaderInterface[] $loaders
23
     */
24 2
    public function __construct(
25
        private KernelInterface $appKernel,
26
        private iterable $loaders
27
    ) {
28 2
    }
29
30
    /**
31
     * {@inheritDoc}
32
     */
33 1
    public function load(Environment $environment): void
34
    {
35 1
        foreach ($this->appKernel->plugins() as $plugin) {
36 1
            $this->process($environment, $plugin);
37
        }
38
    }
39
40
    /**
41
     * @throws Error
42
     * @throws LoaderError
43
     */
44 1
    protected function process(Environment $environment, object $plugin): void
45
    {
46 1
        foreach ($this->loaders as $loader) {
47 1
            $loader->load($environment, $plugin);
48
        }
49
    }
50
}
51