Completed
Push — master ( abc53f...bc5893 )
by Brad
10:23
created

GenerateTransition::getDefaultNamespace()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
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
    protected function getStub()
29
    {
30
        if ($this->option('request-only')) {
31
            return __DIR__ . '/../../stubs/request_only_transition.stub';
32
        }
33
        if ($this->option('response-only')) {
34
            return __DIR__ . '/../../stubs/response_only_transition.stub';
35
        }
36
37
        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
    protected function buildClass($name)
47
    {
48
49
        $stub = $this->files->get($this->getStub());
50
51
        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
    protected function getDefaultNamespace($rootNamespace)
61
    {
62
63
        return "$rootNamespace\\Http\\Transitions";
64
    }
65
}
66