Completed
Push — master ( ec95d0...1ede21 )
by Dmitry
03:27
created

Bootstrap   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 6
lcom 0
cbo 4
dl 0
loc 34
ccs 0
cts 25
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B run() 0 31 6
1
<?php
2
3
namespace Basis\Job\Module;
4
5
use Basis\Dispatcher;
6
use Basis\Event;
7
use Basis\Filesystem;
8
use Basis\Framework;
9
use Basis\Runner;
10
use Basis\Service;
11
use Exception;
12
use ReflectionClass;
13
use ReflectionProperty;
14
15
class Bootstrap
16
{
17
    public function run(Runner $runner, Dispatcher $dispatcher, Service $service, Event $event, Framework $framework, Filesystem $fs)
18
    {
19
        $service->register();
20
21
        $runner->dispatch('tarantool.migrate');
22
23
        $meta = $runner->dispatch('module.meta');
24
        foreach ($meta['routes'] as $route) {
25
            $service->registerRoute($route);
26
        }
27
28
        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...
29
            $service->subscribe($event);
30
        }
31
32
        foreach ($framework->listFiles('resources/default') as $file) {
33
            if (!$fs->exists($file)) {
34
                $source = $framework->getPath("resources/default/$file");
35
                $destination = $fs->getPath($file);
36
                file_put_contents($destination, file_get_contents($source));
37
            }
38
        }
39
40
        $assets = $runner->dispatch('module.assets');
41
42
        ($service->getName() == 'web' ? $runner : $dispatcher)
43
            ->dispatch('asset.register', [
44
                'service' => $service->getName(),
45
                'hash' => $assets['hash'],
46
            ]);
47
    }
48
}
49