Completed
Push — master ( a02954...8fdef2 )
by Elf
03:38
created

ConsoleServiceProvider   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 1
dl 0
loc 47
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A register() 0 12 3
A provides() 0 4 1
1
<?php
2
3
namespace ElfSundae\Laravel\Api\Console;
4
5
use Illuminate\Support\ServiceProvider;
6
7
class ConsoleServiceProvider extends ServiceProvider
8
{
9
    /**
10
     * Indicates if loading of the provider is deferred.
11
     *
12
     * @var bool
13
     */
14
    protected $defer = true;
15
16
    /**
17
     * The commands to be registered.
18
     *
19
     * @var array
20
     */
21
    protected $commands = [
22
        'GenerateClient' => 'command.api.generate.client',
23
        'GenerateToken' => 'command.api.generate.token',
24
    ];
25
26
    /**
27
     * Register the service provider.
28
     *
29
     * @return void
30
     */
31
    public function register()
32
    {
33
        foreach ($this->commands as $key => $value) {
34
            if (method_exists($this, $method = "register{$key}Command")) {
35
                call_user_func_array([$this, $method], [$value]);
36
            } else {
37
                $this->app->singleton($value, __NAMESPACE__.'\\Commands\\'.$key);
38
            }
39
        }
40
41
        $this->commands(array_values($this->commands));
42
    }
43
44
    /**
45
     * Get the services provided by the provider.
46
     *
47
     * @return string[]
48
     */
49
    public function provides()
50
    {
51
        return array_values($this->commands);
52
    }
53
}
54