Completed
Push — master ( 852192...fe2434 )
by Dmitry
05:04
created

Bootstrap::run()   B

Complexity

Conditions 5
Paths 12

Size

Total Lines 25
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 30

Importance

Changes 4
Bugs 0 Features 0
Metric Value
dl 0
loc 25
ccs 0
cts 21
cp 0
rs 8.439
c 4
b 0
f 0
cc 5
eloc 15
nc 12
nop 3
crap 30
1
<?php
2
3
namespace Basis\Jobs\Module;
4
5
use Basis\Converter;
6
use Basis\Event;
7
use Basis\Filesystem;
8
use Basis\Runner;
9
use Basis\Service;
10
use Exception;
11
use ReflectionClass;
12
use ReflectionProperty;
13
14
class Bootstrap
15
{
16
    public function run(Runner $runner, Service $service, Event $event)
17
    {
18
        $runner->dispatch('tarantool.migrate');
19
20
        $meta = $runner->dispatch('module.meta');
21
        foreach ($meta['jobs'] as $job) {
22
            $class = new ReflectionClass($runner->getJobClass($job));
23
            $params = [];
24
            foreach ($class->getProperties(ReflectionProperty::IS_PUBLIC) as $property) {
25
                $params[] = $property->getName();
26
            }
27
            $service->registerJob($job, $params);
28
        }
29
30
        foreach ($meta['routes'] as $route) {
31
            $service->registerRoute($route);
32
        }
33
34
        foreach ($event->getSubscription() as $event => $listeners) {
0 ignored issues
show
Bug introduced by
It seems like $event is not always an object, but can also be of type integer|string. Maybe add an additional type check?

If a variable is not always an object, we recommend to add an additional type check to ensure your method call is safe:

function someFunction(A $objectMaybe = null)
{
    if ($objectMaybe instanceof A) {
        $objectMaybe->doSomething();
    }
}
Loading history...
35
            $service->subscribe($event);
36
        }
37
38
        $assets = $runner->dispatch('module.assets');
39
        $service->updateAssetsVersion($assets['hash']);
40
    }
41
}
42