Completed
Push — master ( fadc66...9ff9d7 )
by Dmitry
03:15
created

Info::run()   B

Complexity

Conditions 5
Paths 7

Size

Total Lines 23
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 30

Importance

Changes 0
Metric Value
dl 0
loc 23
ccs 0
cts 20
cp 0
rs 8.5906
c 0
b 0
f 0
cc 5
eloc 14
nc 7
nop 1
crap 30
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
    public function run(Runner $runner)
14
    {
15
        $jobs = $runner->listJobs();
16
17
        $info = [];
18
        foreach($jobs as $nick => $class) {
19
            // get comment
20
            $reflection = new ReflectionClass($class);
21
            $comments = [];
22
            foreach(explode(PHP_EOL, $reflection->getDocComment()) as $line) {
23
                if(!in_array(substr($line, 0, 3), ['/**', ' */'])) {
24
                    $comments[] = trim(substr($line, 2));
25
                }
26
            }
27
            $comment = implode(PHP_EOL, $comments);
28
            if(!$comment) {
29
                $comment = '-';
30
            }
31
            $info[] = compact('nick', 'class', 'comment');
32
        }
33
34
        return compact('info');
35
    }
36
}