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

BootstrapRunner::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 4
ccs 0
cts 3
cp 0
crap 2
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