GenerateTransition::getStub()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 3

Importance

Changes 0
Metric Value
dl 0
loc 11
ccs 6
cts 6
cp 1
rs 9.9
c 0
b 0
f 0
cc 3
nc 3
nop 0
crap 3
1
<?php
2
3
namespace Transitions\Console;
4
5
use Illuminate\Console\GeneratorCommand;
6
7
class GenerateTransition extends GeneratorCommand
8
{
9
10
    /**
11
     * The name and signature of the console command.
12
     *
13
     * @var string
14
     */
15
    protected $signature = 'make:transition {name} {--request-only} {--response-only}';
16
    /**
17
     * The console command description.
18
     *
19
     * @var string
20
     */
21
    protected $description = 'Create an HTTP transition';
22
23
    /**
24
     * Get the stub file for the generator.
25
     *
26
     * @return string
27
     */
28 9
    protected function getStub()
29
    {
30 9
        if ($this->option('request-only')) {
31 3
            return __DIR__ . '/../../stubs/request_only_transition.stub';
32
        }
33 6
        if ($this->option('response-only')) {
34 3
            return __DIR__ . '/../../stubs/response_only_transition.stub';
35
        }
36
37 3
        return __DIR__ . '/../../stubs/transition.stub';
38
    }
39
40
    /**
41
     * Build the model class with the given name.
42
     *
43
     * @param  string $name
44
     * @return string
45
     */
46 9
    protected function buildClass($name)
47
    {
48
49 9
        $stub = $this->files->get($this->getStub());
50
51 9
        return $this->replaceNamespace($stub, $name)->replaceClass($stub, $name);
52
    }
53
54
    /**
55
     * Get the default namespace for the class.
56
     *
57
     * @param  string $rootNamespace
58
     * @return string
59
     */
60 9
    protected function getDefaultNamespace($rootNamespace)
61
    {
62
63 9
        return "$rootNamespace\\Http\\Transitions";
64
    }
65
}
66