Completed
Push — master ( 5a6cbe...c8e6dd )
by Dmitry
05:03
created

Meta::run()   B

Complexity

Conditions 5
Paths 9

Size

Total Lines 21
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 13
CRAP Score 5

Importance

Changes 0
Metric Value
dl 0
loc 21
ccs 13
cts 13
cp 1
rs 8.7624
c 0
b 0
f 0
cc 5
eloc 13
nc 9
nop 1
crap 5
1
<?php
2
3
namespace Basis\Job\Module;
4
5
use Basis\Filesystem;
6
use ReflectionClass;
7
use ReflectionMethod;
8
9
class Meta
10
{
11 2
    public function run(Filesystem $fs)
12
    {
13 2
        $routes = [];
14 2
        foreach ($fs->listClasses('Controller') as $class) {
15 2
            $nick = substr(strtolower($class), 11);
16 2
            $methods = (new ReflectionClass($class))->getMethods(ReflectionMethod::IS_PUBLIC);
17 2
            foreach ($methods as $method) {
18 2
                $routes[] = $nick.'/'.$method->getName();
0 ignored issues
show
Bug introduced by
Consider using $method->name. There is an issue with getName() and APC-enabled PHP versions.
Loading history...
19
            }
20
        }
21
22 2
        $jobs = [];
23 2
        foreach ($fs->listClasses('Job') as $class) {
24 2
            $reflection = new ReflectionClass($class);
25 2
            if (!$reflection->isAbstract()) {
26 2
                $jobs[] = str_replace('\\', '.', substr(strtolower($class), 4));
27
            }
28
        }
29
30 2
        return compact('routes', 'jobs');
31
    }
32
}
33