MakeFormatterCommand::getStub()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 3
c 1
b 0
f 0
nc 2
nop 0
dl 0
loc 5
ccs 3
cts 3
cp 1
crap 2
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace MichaelRubel\Formatters\Commands;
6
7
use Illuminate\Console\GeneratorCommand;
8
use Symfony\Component\Console\Input\InputOption;
9
10
class MakeFormatterCommand extends GeneratorCommand
11
{
12
    /**
13
     * @var string
14
     */
15
    protected $name = 'make:formatter';
16
17
    /**
18
     * @var string
19
     */
20
    protected $description = 'Create the formatter class';
21
22
    /**
23
     * @var string
24
     */
25
    protected $type = 'Formatter';
26
27
    /**
28
     * Specify your Stub's location.
29
     *
30
     * @return string
31
     */
32 2
    protected function getStub(): string
33
    {
34 2
        return file_exists($customPath = $this->laravel->basePath('/stubs/formatter.stub'))
35
            ? $customPath // @codeCoverageIgnore
36 2
            : __DIR__ . '/stubs/formatter.stub';
37
    }
38
39
    /**
40
     * Get the default namespace for the class.
41
     *
42
     * @param  string  $rootNamespace
43
     *
44
     * @return string
45
     */
46 6
    protected function getDefaultNamespace($rootNamespace): string
47
    {
48 6
        return $rootNamespace . '\\Formatters';
49
    }
50
51
    /**
52
     * Get the console command options.
53
     *
54
     * @return array
55
     */
56 7
    protected function getOptions(): array
57
    {
58 7
        return [
59 7
            ['formatter', null, InputOption::VALUE_NONE, 'Create the formatter class'],
60 7
        ];
61
    }
62
}
63