ConsoleMakeService   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 74
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 14
dl 0
loc 74
rs 10
c 1
b 0
f 0
wmc 5

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getDefaultNamespace() 0 3 1
A getStub() 0 11 2
A getOptions() 0 4 1
A getArguments() 0 4 1
1
<?php
2
3
namespace Zendaemon\Services\Console;
4
5
use Illuminate\Console\GeneratorCommand;
6
use Symfony\Component\Console\Input\InputArgument;
7
use Symfony\Component\Console\Input\InputOption;
8
9
class ConsoleMakeService extends GeneratorCommand
10
{
11
    /**
12
     * The console command name.
13
     *
14
     * @var string
15
     */
16
    protected $name = 'make:service';
17
18
    /**
19
     * The console command description.
20
     *
21
     * @var string
22
     */
23
    protected $description = 'Create a new service class';
24
25
    /**
26
     * The type of class being generated.
27
     *
28
     * @var string
29
     */
30
    protected $type = 'Service';
31
32
    /**
33
     * Get the stub file for the generator.
34
     *
35
     * @return string
36
     */
37
    protected function getStub()
38
    {
39
        $stub = null;
40
41
        if ($this->option('static')) {
42
            $stub = '/stubs/service.static.stub';
43
        }
44
45
        $stub = $stub ?? '/stubs/service.stub';
46
47
        return __DIR__.$stub;
48
    }
49
50
    /**
51
     * Get the default namespace for the class.
52
     *
53
     * @param string $rootNamespace
54
     *
55
     * @return string
56
     */
57
    protected function getDefaultNamespace($rootNamespace)
58
    {
59
        return $rootNamespace.'\Services';
60
    }
61
62
    /**
63
     * Get the console command arguments.
64
     *
65
     * @return array
66
     */
67
    protected function getArguments()
68
    {
69
        return [
70
            ['name', InputArgument::REQUIRED, 'The name of the service'],
71
        ];
72
    }
73
74
    /**
75
     * Get the console command options.
76
     *
77
     * @return array
78
     */
79
    protected function getOptions()
80
    {
81
        return [
82
            ['static', 's', InputOption::VALUE_NONE, 'Generate a static service.'],
83
        ];
84
    }
85
}
86