Completed
Push — master ( 1cd9a0...4f8c6b )
by Dmitry
04:09
created

Bootstrap   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 8
lcom 0
cbo 3
dl 0
loc 29
ccs 0
cts 23
cp 0
rs 10
c 1
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
C run() 0 26 8
1
<?php
2
3
namespace Basis\Jobs\Module;
4
5
use Basis\Config;
6
use Basis\Event;
7
use Basis\Runner;
8
use LinkORB\Component\Etcd\Client;
9
10
class Bootstrap
11
{
12
    public function run(Runner $runner, Client $client, Config $config, Event $event)
0 ignored issues
show
Unused Code introduced by
The parameter $event is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
13
    {
14
        $runner->dispatch('tarantool.migrate');
15
16
        $client->setRoot('services');
17
        if(!$client->get($config['name'])) {
18
            $client->set($config['name']);
0 ignored issues
show
Bug introduced by
The call to set() misses a required argument $value.

This check looks for function calls that miss required arguments.

Loading history...
19
        }
20
21
        $client->setRoot('jobs');
22
        $meta = $runner->dispatch('module.meta');
23
        foreach($meta['jobs'] as $job) {
24
            if(!$client->get($job)) {
25
                $client->set($job, $config['name']);
26
            }
27
        }
28
29
        if($config->offsetExists('events') && is_array($config['events'])) {
30
            foreach($config['events'] as $event => $listeners) {
31
                $listeners = (array) $listeners;
32
                foreach($listeners as $listener) {
33
                    $event->subscribe($event, $listener);
0 ignored issues
show
Bug introduced by
The method subscribe cannot be called on $event (of type integer|string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
34
                }
35
            }
36
        }
37
    }
38
}
39