Completed
Push — master ( 56489c...36ced6 )
by Dmitry
02:32
created

Meta::run()   B

Complexity

Conditions 6
Paths 16

Size

Total Lines 27
Code Lines 17

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 42

Importance

Changes 0
Metric Value
dl 0
loc 27
ccs 0
cts 21
cp 0
rs 8.439
c 0
b 0
f 0
cc 6
eloc 17
nc 16
nop 1
crap 42
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
    public function run(Filesystem $fs)
12
    {
13
        $routes = [];
14
        foreach($fs->listClasses('Controllers') as $class) {
15
            $nick = substr(strtolower($class), 12);
16
            $methods = (new ReflectionClass($class))->getMethods(ReflectionMethod::IS_PUBLIC);
17
            foreach($methods as $method) {
18
                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
                    $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
                    $routes[] = $nick;
22
                }
23
            }
24
        }
25
26
        $jobs = [];
27
        foreach($fs->listClasses('Jobs') as $class) {
28
            $jobs[] = str_replace('\\', '.', substr(strtolower($class), 5));
29
        }
30
31
        $js = [];
32
        foreach($fs->listFiles('src/js') as $file) {
33
            $js[] = str_replace('/', '.', substr($file, 0, -3));
34
        }
35
36
        return compact('routes', 'jobs', 'js');
37
    }
38
}