Meta   A
last analyzed

Complexity

Total Complexity 14

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 14
lcom 0
cbo 2
dl 0
loc 47
ccs 28
cts 28
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
C run() 0 44 14
1
<?php
2
3
namespace Basis\Job\Module;
4
5
use Basis\Filesystem;
6
use Basis\Job;
7
use ReflectionClass;
8
use ReflectionMethod;
9
10
class Meta extends Job
11
{
12 4
    public function run(Filesystem $fs)
13
    {
14 4
        $routes = [];
15 4
        foreach ($fs->listClasses('Controller') as $class) {
16 4
            $nick = substr(strtolower($class), 11);
17 4
            $reflectionClass =new ReflectionClass($class);
18 4
            $traits = $reflectionClass->getTraits();
19 4
            $ignore = [];
20 4
            if (count($traits)) {
21 4
                foreach ($traits as $trait) {
22 4
                    foreach ($trait->getMethods(ReflectionMethod::IS_PUBLIC) as $method) {
23 4
                        if ($method->isConstructor() || $method->getName() == '__debugInfo') {
24 4
                            continue;
25
                        }
26 4
                        $ignore[] = $method->getName();
27
                    }
28
                }
29
            }
30 4
            $methods = $reflectionClass->getMethods(ReflectionMethod::IS_PUBLIC);
31 4
            foreach ($methods as $method) {
32 4
                if ($method->isConstructor() || $method->getName() == '__debugInfo') {
0 ignored issues
show
Bug introduced by
Consider using $method->name. There is an issue with getName() and APC-enabled PHP versions.
Loading history...
33 4
                    continue;
34
                }
35 4
                if (in_array($method->name, $ignore)) {
36 4
                    continue;
37
                }
38 4
                if ($method->name == '__process') {
39 4
                    $routes[] = $nick.'/*';
40
                } else {
41 4
                    $routes[] = $nick.'/'.$method->name;
42
                }
43
            }
44
        }
45
46 4
        $jobs = [];
47 4
        foreach ($fs->listClasses('Job') as $class) {
48 4
            $reflection = new ReflectionClass($class);
49 4
            if (!$reflection->isAbstract()) {
50 4
                $jobs[] = str_replace('\\', '.', substr(strtolower($class), 4));
51
            }
52
        }
53
54 4
        return compact('routes', 'jobs');
55
    }
56
}
57