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

Bootstrap   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 4
Bugs 0 Features 0
Metric Value
wmc 5
lcom 0
cbo 2
dl 0
loc 28
ccs 0
cts 21
cp 0
rs 10
c 4
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B run() 0 25 5
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