Completed
Push — master ( ae18f5...850931 )
by Nicolas
02:43 queued 54s
created

ComponentViewMakeCommand::getTemplateContents()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Nwidart\Modules\Commands;
4
5
use Illuminate\Support\Str;
6
use Nwidart\Modules\Support\Stub;
7
use Illuminate\Foundation\Inspiring;
8
use Nwidart\Modules\Traits\ModuleCommandTrait;
9
use Symfony\Component\Console\Input\InputArgument;
10
use Nwidart\Modules\Support\Config\GenerateConfigReader;
11
12
class ComponentViewMakeCommand extends GeneratorCommand
13
{
14
    use ModuleCommandTrait;
15
16
    /**
17
     * The name of argument name.
18
     *
19
     * @var string
20
     */
21
    protected $argumentName = 'name';
22
23
    /**
24
     * The console command name.
25
     *
26
     * @var string
27
     */
28
    protected $name = 'module:make-component-view';
29
30
    /**
31
     * The console command description.
32
     *
33
     * @var string
34
     */
35
    protected $description = 'Create a new component-view for the specified module.';
36
37
    /**
38
     * Get the console command arguments.
39
     *
40
     * @return array
41
     */
42
    protected function getArguments()
43
    {
44
        return [
45
            ['name', InputArgument::REQUIRED, 'The name of the component.'],
46
            ['module', InputArgument::OPTIONAL, 'The name of module will be used.'],
47
        ];
48
    }
49
50
    /**
51
     * @return mixed
52
     */
53
    protected function getTemplateContents()
54
    {
55
        return (new Stub('/component-view.stub',['QUOTE'=> Inspiring::quote()]))->render();
56
    }
57
58
    /**
59
     * @return mixed
60
     */
61
    protected function getDestinationFilePath()
62
    {
63
        $path = $this->laravel['modules']->getModulePath($this->getModuleName());
64
        $factoryPath = GenerateConfigReader::read('component-view');
65
        return $path . $factoryPath->getPath() . '/' . $this->getFileName();
66
    }
67
68
    /**
69
     * @return string
70
     */
71
    private function getFileName()
72
    {
73
        return Str::lower($this->argument('name')) . '.blade.php';
0 ignored issues
show
Bug introduced by
It seems like $this->argument('name') targeting Illuminate\Console\Conce...ractsWithIO::argument() can also be of type array or null; however, Illuminate\Support\Str::lower() does only seem to accept string, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
74
    }
75
}
76