Completed
Push — master ( c132c8...42afef )
by Dmitry
06:08
created

Info   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 3
Bugs 0 Features 3
Metric Value
wmc 5
c 3
b 0
f 3
lcom 0
cbo 1
dl 0
loc 26
ccs 14
cts 14
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B run() 0 23 5
1
<?php
2
3
namespace Basis\Jobs\Job;
4
5
use Basis\Runner;
6
use ReflectionClass;
7
8
/**
9
 * Get Jobs information
10
 */
11
class Info
12
{
13 1
    function run(Runner $runner)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
14
    {
15 1
        $jobs = $runner->listJobs();
16
17 1
        $info = [];
18 1
        foreach($jobs as $nick => $class) {
19
            // get comment
20 1
            $reflection = new ReflectionClass($class);
21 1
            $comments = [];
22 1
            foreach(explode(PHP_EOL, $reflection->getDocComment()) as $line) {
23 1
                if(!in_array(substr($line, 0, 3), ['/**', ' */'])) {
24 1
                    $comments[] = trim(substr($line, 2));
25
                }
26
            }
27 1
            $comment = implode(PHP_EOL, $comments);
28 1
            if(!$comment) {
29 1
                $comment = '-';
30
            }
31 1
            $info[] = compact('nick', 'class', 'comment');
32
        }
33
34 1
        return compact('info');
35
    }
36
}