Passed
Push — main ( 8010ea...80f2b7 )
by Yunfeng
52s queued 14s
created

EnumMetaMakeCommand::getStub()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 4
c 1
b 0
f 0
nc 2
nop 0
dl 0
loc 7
rs 10
1
<?php
2
3
namespace BiiiiiigMonster\LaravelEnum\Commands;
4
5
use Illuminate\Console\GeneratorCommand;
6
use Symfony\Component\Console\Attribute\AsCommand;
7
use Symfony\Component\Console\Input\InputOption;
8
9
#[AsCommand(name: 'make:enumMeta')]
10
class EnumMetaMakeCommand extends GeneratorCommand
11
{
12
    /**
13
     * The console command name.
14
     *
15
     * @var string
16
     */
17
    protected $name = 'make:enumMeta';
18
19
    /**
20
     * The console command description.
21
     *
22
     * @var string
23
     */
24
    protected $description = 'Create a new custom enum meta attribute.';
25
26
    /**
27
     * The type of class being generated.
28
     *
29
     * @var string
30
     */
31
    protected $type = 'EnumMeta';
32
33
    /**
34
     * Get the stub file for the generator.
35
     *
36
     * @return string
37
     */
38
    protected function getStub()
39
    {
40
        $relativePath = '/stubs/enum_meta.stub';
41
42
        return file_exists($customPath = $this->laravel->basePath(trim($relativePath, '/')))
43
            ? $customPath
44
            : __DIR__.$relativePath;
45
    }
46
47
    /**
48
     * Get the default namespace for the class.
49
     *
50
     * @param  string  $rootNamespace
51
     * @return string
52
     */
53
    protected function getDefaultNamespace($rootNamespace)
54
    {
55
        return $rootNamespace.'\Enums\Metas';
56
    }
57
58
    /**
59
     * Get the console command arguments.
60
     *
61
     * @return array
62
     */
63
    protected function getOptions()
64
    {
65
        return [
66
            ['force', 'f', InputOption::VALUE_NONE, 'Create the class even if the enum meta already exists'],
67
        ];
68
    }
69
}
70