Completed
Push — master ( 346e09...46a5ae )
by Dmitry
06:10
created

Bootstrap   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 24
Duplicated Lines 16.67 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 3
Bugs 0 Features 0
Metric Value
wmc 4
lcom 0
cbo 3
dl 4
loc 24
rs 10
c 3
b 0
f 0
ccs 0
cts 19
cp 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A run() 4 21 4

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace Basis\Jobs\Module;
4
5
use Basis\Filesystem;
6
use Basis\Etcd;
7
use Basis\Runner;
8
use Exception;
9
use ReflectionClass;
10
use ReflectionProperty;
11
12
class Bootstrap
13
{
14
    public function run(Runner $runner, Etcd $etcd, Filesystem $fs)
15
    {
16
        $runner->dispatch('tarantool.migrate');
17
18
        $etcd->registerService();
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
            $etcd->registerJob($job, $params);
28
        }
29
30 View Code Duplication
        foreach($fs->listClasses('Listeners') as $class) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
31
            $event = str_replace('\\', '.', substr(strtolower($class), 10));
32
            $etcd->subscribe($event);
33
        }
34
    }
35
}
36