CustomRuleMakeCommand::getNameInput()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 11

Duplication

Lines 11
Ratio 100 %

Importance

Changes 0
Metric Value
dl 11
loc 11
rs 9.9
c 0
b 0
f 0
cc 2
nc 2
nop 0
1
<?php
2
3
namespace PerfectOblivion\Valid\Commands;
4
5
use Illuminate\Support\Facades\Config;
6
use Illuminate\Console\GeneratorCommand;
7
8 View Code Duplication
class CustomRuleMakeCommand extends GeneratorCommand
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
9
{
10
    /**
11
     * The console command signature.
12
     *
13
     * @var string
14
     */
15
    protected $signature = 'adr:rule {name}';
16
17
    /**
18
     * The console command description.
19
     *
20
     * @var string
21
     */
22
    protected $description = 'Create a new Custom Rule';
23
24
    /**
25
     * The type of class being generated.
26
     *
27
     * @var string
28
     */
29
    protected $type = 'Custom Rule';
30
31
    /**
32
     * Get the stub file for the generator.
33
     *
34
     * @return string
35
     */
36
    protected function getStub()
37
    {
38
        return __DIR__.'/stubs/custom-rule.stub';
39
    }
40
41
    /**
42
     * Get the default namespace for the class.
43
     *
44
     * @param  string  $rootNamespace
45
     *
46
     * @return string
47
     */
48
    protected function getDefaultNamespace($rootNamespace)
49
    {
50
        $namespace = studly_case(trim(Config::get('valid.rules.namespace')));
51
52
        return $namespace ? $rootNamespace.'\\'.$namespace : $rootNamespace;
53
    }
54
55
    /**
56
     * Get the desired class name from the input.
57
     *
58
     * @return string
59
     */
60
    protected function getNameInput()
61
    {
62
        $input = studly_case(trim($this->argument('name')));
63
        $ruleSuffix = Config::get('valid.rules.suffix');
64
65
        if (Config::get('valid.rules.override_duplicate_suffix')) {
66
            return str_finish($input, $ruleSuffix);
67
        }
68
69
        return $input.$ruleSuffix;
70
    }
71
}
72