BootstrapRunner   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A run() 0 13 3
A __construct() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Yii\Runner;
6
7
use Psr\Container\ContainerInterface;
8
use RuntimeException;
9
10
use function get_debug_type;
11
use function is_callable;
12
use function sprintf;
13
14
/**
15
 * Runs application bootstrap configs.
16
 */
17
final class BootstrapRunner implements RunnerInterface
18
{
19 5
    public function __construct(
20
        private ContainerInterface $container,
21
        private array $bootstrapList = [],
22
    ) {
23 5
    }
24
25
    /**
26
     * @throws RuntimeException If the bootstrap callback is not callable.
27
     */
28 5
    public function run(): void
29
    {
30 5
        foreach ($this->bootstrapList as $callback) {
31 5
            if (!is_callable($callback)) {
32 1
                throw new RuntimeException(
33 1
                    sprintf(
34 1
                        'Bootstrap callback must be callable, "%s" given.',
35 1
                        get_debug_type($callback),
36 1
                    )
37 1
                );
38
            }
39
40 4
            $callback($this->container);
41
        }
42
    }
43
}
44