Completed
Push — master ( 9ff9d7...8b6791 )
by Dmitry
03:09
created

Info::run()   B

Complexity

Conditions 5
Paths 7

Size

Total Lines 23
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 18
CRAP Score 5

Importance

Changes 0
Metric Value
dl 0
loc 23
ccs 18
cts 18
cp 1
rs 8.5906
c 0
b 0
f 0
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
    public function run(Runner $runner)
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 1
                }
26 1
            }
27 1
            $comment = implode(PHP_EOL, $comments);
28 1
            if(!$comment) {
29 1
                $comment = '-';
30 1
            }
31 1
            $info[] = compact('nick', 'class', 'comment');
32 1
        }
33
34 1
        return compact('info');
35
    }
36
}