Conditions | 6 |
Paths | 5 |
Total Lines | 26 |
Code Lines | 14 |
Lines | 0 |
Ratio | 0 % |
Changes | 9 | ||
Bugs | 1 | Features | 1 |
1 | <?php |
||
20 | public function loadFor(Schedule $schedule, array $exclude = []) |
||
21 | { |
||
22 | $namespace = $this->app->getNamespace(); |
||
23 | |||
24 | $path = $this->app->path('Console/Tasks'); |
||
25 | |||
26 | if (! is_dir($path)) { |
||
27 | return; |
||
28 | } |
||
29 | |||
30 | foreach ((new Finder)->in($path)->files() as $taskFile) { |
||
31 | $task = $namespace.str_replace( |
||
32 | ['/', '.php'], |
||
33 | ['\\', ''], |
||
34 | Str::after($taskFile->getPathname(), $this->app->path().DIRECTORY_SEPARATOR) |
||
35 | ); |
||
36 | |||
37 | if (in_array($task, $exclude)) { |
||
38 | continue; |
||
39 | } |
||
40 | |||
41 | if (is_subclass_of($task, TaskContract::class) && |
||
42 | ! (new ReflectionClass($task))->isAbstract()) { |
||
43 | |||
44 | // Invoke task |
||
45 | app($task)($schedule); |
||
46 | } |
||
50 |