Test Failed
Push — main ( 8c0949...0df40c )
by Michael
03:37
created

ValueObjectMakeCommand   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 62
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 5
eloc 11
c 0
b 0
f 0
dl 0
loc 62
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A resolveStubPath() 0 5 2
A getDefaultNamespace() 0 3 1
A getOptions() 0 4 1
A getStub() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace MichaelRubel\ValueObjects\Artisan;
6
7
use Illuminate\Console\GeneratorCommand;
8
use Symfony\Component\Console\Input\InputOption;
9
10
class ValueObjectMakeCommand extends GeneratorCommand
11
{
12
    /**
13
     * @var string
14
     */
15
    protected $name = 'make:value-object';
16
17
    /**
18
     * @var string
19
     */
20
    protected $description = 'Create a value object';
21
22
    /**
23
     * @var string
24
     */
25
    protected $type = 'Value Object';
26
27
    /**
28
     * Specify your Stub's location.
29
     *
30
     * @return string
31
     */
32
    protected function getStub(): string
33
    {
34
        return $this->resolveStubPath('/stubs/value-object.stub');
35
    }
36
37
    /**
38
     * Resolve the fully-qualified path to the stub.
39
     *
40
     * @param  string  $stub
41
     *
42
     * @return string
43
     */
44
    protected function resolveStubPath(string $stub): string
45
    {
46
        return file_exists($customPath = $this->laravel->basePath(trim($stub, '/')))
47
            ? $customPath // @codeCoverageIgnore
48
            : __DIR__ . $stub;
49
    }
50
51
    /**
52
     * Get the default namespace for the class.
53
     *
54
     * @param  string  $rootNamespace
55
     *
56
     * @return string
57
     */
58
    protected function getDefaultNamespace($rootNamespace): string
59
    {
60
        return $rootNamespace . '\\ValueObjects';
61
    }
62
63
    /**
64
     * Get the console command options.
65
     *
66
     * @return array
67
     */
68
    protected function getOptions(): array
69
    {
70
        return [
71
            ['value-object', null, InputOption::VALUE_NONE, 'Create a value object'],
72
        ];
73
    }
74
}
75