Completed
Push — master ( e7b929...ba2691 )
by Dmitry
03:11
created

Meta::run()   B

Complexity

Conditions 5
Paths 9

Size

Total Lines 21
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 30

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 21
ccs 0
cts 19
cp 0
rs 8.7624
cc 5
eloc 13
nc 9
nop 2
crap 30
1
<?php
2
3
namespace Basis\Job\Module;
4
5
use Basis\Config;
6
use Basis\Filesystem;
7
use Basis\Job;
8
use ReflectionClass;
9
use ReflectionMethod;
10
11
class Meta extends Job
12
{
13
    public function run(Filesystem $fs, Config $config)
0 ignored issues
show
Unused Code introduced by
The parameter $config is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
14
    {
15
        $routes = [];
16
        foreach ($fs->listClasses('Controller') as $class) {
17
            $nick = substr(strtolower($class), 11);
18
            $methods = (new ReflectionClass($class))->getMethods(ReflectionMethod::IS_PUBLIC);
19
            foreach ($methods as $method) {
20
                $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...
21
            }
22
        }
23
24
        $jobs = [];
25
        foreach ($fs->listClasses('Job') as $class) {
26
            $reflection = new ReflectionClass($class);
27
            if (!$reflection->isAbstract()) {
28
                $jobs[] = str_replace('\\', '.', substr(strtolower($class), 4));
29
            }
30
        }
31
32
        return compact('routes', 'jobs');
33
    }
34
}
35