Completed
Push — master ( f239fd...7f9950 )
by Dmitry
03:55
created

Meta::run()   B

Complexity

Conditions 5
Paths 8

Size

Total Lines 22
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 13
CRAP Score 5

Importance

Changes 0
Metric Value
dl 0
loc 22
ccs 13
cts 13
cp 1
rs 8.6737
c 0
b 0
f 0
cc 5
eloc 14
nc 8
nop 1
crap 5
1
<?php
2
3
namespace Basis\Jobs\Module;
4
5
use Basis\Filesystem;
6
use ReflectionClass;
7
use ReflectionMethod;
8
9
class Meta
10
{
11 1
    public function run(Filesystem $fs)
12
    {
13 1
        $routes = [];
14 1
        foreach($fs->listClasses('Controllers') as $class) {
15 1
            $nick = substr(strtolower($class), 12);
16 1
            $methods = (new ReflectionClass($class))->getMethods(ReflectionMethod::IS_PUBLIC);
17 1
            foreach($methods as $method) {
18 1
                if($method->getName() != 'index') {
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 1
                    $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...
20
                } else {
21 1
                    $routes[] = $nick;
22
                }
23
            }
24
        }
25
26 1
        $jobs = [];
27 1
        foreach($fs->listClasses('Jobs') as $class) {
28 1
            $jobs[] = str_replace('\\', '.', substr(strtolower($class), 5));
29
        }
30
31 1
        return compact('routes', 'jobs');
32
    }
33
}