Completed
Push — master ( 95b8e4...b19727 )
by Dmitry
06:52
created

src/Job/Module/Meta.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

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 7
    public function run(Filesystem $fs)
13
    {
14 7
        $routes = [];
15 7
        foreach ($fs->listClasses('Controller') as $class) {
16 7
            $nick = substr(strtolower($class), 11);
17 7
            $methods = (new ReflectionClass($class))->getMethods(ReflectionMethod::IS_PUBLIC);
18 7
            foreach ($methods as $method) {
19 7
                if ($method->isConstructor() || $method->getName() == '__debugInfo') {
0 ignored issues
show
Consider using $method->name. There is an issue with getName() and APC-enabled PHP versions.
Loading history...
20 7
                    continue;
21
                }
22 7
                if ($method->name == '__process') {
23 7
                    $routes[] = $nick.'/*';
24
                } else {
25 7
                    $routes[] = $nick.'/'.$method->name;
26
                }
27
            }
28
        }
29
30 7
        $jobs = [];
31 7
        foreach ($fs->listClasses('Job') as $class) {
32 7
            $reflection = new ReflectionClass($class);
33 7
            if (!$reflection->isAbstract()) {
34 7
                $jobs[] = str_replace('\\', '.', substr(strtolower($class), 4));
35
            }
36
        }
37
38 7
        return compact('routes', 'jobs');
39
    }
40
}
41