Passed
Push — master ( 8241e4...1bc467 )
by Alexander
03:14
created

BootstrapRunner   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Test Coverage

Coverage 60%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 9
c 1
b 0
f 0
dl 0
loc 19
ccs 6
cts 10
cp 0.6
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A run() 0 8 3
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 14
    public function __construct(ContainerInterface $container, array $bootstrapList = [])
19
    {
20 14
        $this->container = $container;
21 14
        $this->bootstrapList = $bootstrapList;
22 14
    }
23
24 14
    public function run(): void
25
    {
26 14
        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 14
    }
34
}
35