1 | <?php |
||
2 | |||
3 | namespace Desemax\ArtisanUI; |
||
4 | |||
5 | use Illuminate\Support\Facades\Artisan; |
||
6 | use Symfony\Component\Console\Command\Command; |
||
7 | |||
8 | class ArtisanUI |
||
9 | { |
||
10 | public function commands() |
||
11 | { |
||
12 | return array_values(array_filter(Artisan::all(), function ($command) { |
||
13 | return ! in_array($this->getNamespace($command), $this->ignoredNamespaces()); |
||
14 | })); |
||
15 | } |
||
16 | |||
17 | public function names() |
||
18 | { |
||
19 | return array_keys($this->commands()); |
||
20 | } |
||
21 | |||
22 | public function namespaces() |
||
23 | { |
||
24 | return array_values(array_unique(array_map(function ($command) { |
||
25 | return $this->getNamespace($command); |
||
26 | }, $this->commands()))); |
||
27 | } |
||
28 | |||
29 | public function getNamespace(Command $command) |
||
30 | { |
||
31 | return explode(':', $command->getName())[0]; |
||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||
32 | } |
||
33 | |||
34 | public function ignoredNamespaces() |
||
35 | { |
||
36 | return array_merge( |
||
37 | config('artisanui.commands.namespaces.excluded.default'), |
||
38 | config('artisanui.commands.namespaces.excluded.custom') |
||
39 | ); |
||
40 | } |
||
41 | } |
||
42 |