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

Info   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 0%

Importance

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

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
    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
}