Passed
Push — master ( 42194e...dbda58 )
by Alexander
03:10
created

BootstrapRunner::run()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 5.667

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 8
ccs 2
cts 6
cp 0.3333
rs 10
cc 3
nc 3
nop 0
crap 5.667
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Runner;
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 7
    public function __construct(ContainerInterface $container, array $bootstrapList = [])
19
    {
20 7
        $this->container = $container;
21 7
        $this->bootstrapList = $bootstrapList;
22 7
    }
23
24 7
    public function run(): void
25
    {
26 7
        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 7
    }
34
}
35