Passed
Push — master ( 527271...9d5350 )
by Alexander
02:35
created

BootstrapRunner::run()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 5
c 1
b 0
f 0
nc 3
nop 0
dl 0
loc 8
ccs 0
cts 6
cp 0
crap 12
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Yii\Runner\RoadRunner;
6
7
use Psr\Container\ContainerInterface;
8
use RuntimeException;
9
10
use function get_debug_type;
11
use function is_callable;
12
13
final class BootstrapRunner
14
{
15
    private ContainerInterface $container;
16
    private array $bootstrapList;
17
18
    public function __construct(ContainerInterface $container, array $bootstrapList = [])
19
    {
20
        $this->container = $container;
21
        $this->bootstrapList = $bootstrapList;
22
    }
23
24
    public function run(): void
25
    {
26
        foreach ($this->bootstrapList as $callback) {
27
            if (!(is_callable($callback))) {
28
                $type = get_debug_type($callback);
29
                throw new RuntimeException("Bootstrap callback must be callable, $type given.");
30
            }
31
            $callback($this->container);
32
        }
33
    }
34
}
35