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

Info::run()   B

Complexity

Conditions 5
Paths 7

Size

Total Lines 23
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 14
CRAP Score 5

Importance

Changes 3
Bugs 0 Features 3
Metric Value
c 3
b 0
f 3
dl 0
loc 23
ccs 14
cts 14
cp 1
rs 8.5906
cc 5
eloc 14
nc 7
nop 1
crap 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
}