Completed
Push — master ( 1fab66...7a7060 )
by Nicolas
02:25
created

RouteProviderMakeCommand::getRoutesPath()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Nwidart\Modules\Commands;
4
5
use Nwidart\Modules\Support\Stub;
6
use Nwidart\Modules\Traits\ModuleCommandTrait;
7
use Symfony\Component\Console\Input\InputArgument;
8
9
class RouteProviderMakeCommand extends GeneratorCommand
10
{
11
    use ModuleCommandTrait;
12
13
    protected $argumentName = 'module';
14
15
    /**
16
     * The command name.
17
     *
18
     * @var string
19
     */
20
    protected $name = 'module:route-provider';
21
22
    /**
23
     * The command description.
24
     *
25
     * @var string
26
     */
27
    protected $description = 'Create a new route service provider for the specified module.';
28
29
    /**
30
     * The command arguments.
31
     *
32
     * @return array
33
     */
34 72
    protected function getArguments()
35
    {
36
        return [
37 72
            ['module', InputArgument::OPTIONAL, 'The name of module will be used.'],
38
        ];
39
    }
40
41
    /**
42
     * Get template contents.
43
     *
44
     * @return string
45
     */
46 2
    protected function getTemplateContents()
47
    {
48 2
        return (new Stub('/route-provider.stub', [
49 2
            'MODULE'           => $this->getModuleName(),
50 2
            'NAME'             => $this->getFileName(),
51 2
            'MODULE_NAMESPACE' => $this->laravel['modules']->config('namespace'),
52 2
            'ROUTES_PATH'   => $this->getRoutesPath(),
53 2
        ]))->render();
54
    }
55
56
    /**
57
     * @return string
58
     */
59 2
    private function getFileName()
60
    {
61 2
        return 'RouteServiceProvider';
62
    }
63
64
    /**
65
     * Get the destination file path.
66
     *
67
     * @return string
68
     */
69 2
    protected function getDestinationFilePath()
70
    {
71 2
        $path = $this->laravel['modules']->getModulePath($this->getModuleName());
72
73 2
        $generatorPath = $this->laravel['modules']->config('paths.generator.provider');
74
75 2
        return $path . $generatorPath . '/' . $this->getFileName() . '.php';
76
    }
77
78
    /**
79
     * @return mixed
80
     */
81 2
    protected function getRoutesPath()
82
    {
83 2
        return '/' . $this->laravel['config']->get('stubs.files.routes', 'Http/routes.php');
84
    }
85
}
86