MakeComponent::getStub()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 6

Duplication

Lines 6
Ratio 100 %

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 1
dl 6
loc 6
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace VueGenerators\Commands;
4
5
use Illuminate\Filesystem\Filesystem;
6
7 View Code Duplication
class MakeComponent extends VueGeneratorsCommand
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...
8
{
9
    /**
10
     * The name and signature of the console command.
11
     *
12
     * @var string
13
     */
14
    protected $signature = 'vueg:component {name} {--empty} {--path=}';
15
16
    /**
17
     * The console command description.
18
     *
19
     * @var string
20
     */
21
    protected $description = 'Create a new Vue js component file.';
22
23
    /**
24
     * Execute the console command.
25
     */
26
    public function handle()
27
    {
28
        $filesystem = new Filesystem();
29
30
        $name = $this->argument('name').'.vue';
31
32
        $path = $this->createPath($filesystem, 'component');
33
34
        $fullPath = resource_path("{$path}/{$name}");
35
36
        $this->checkFileExists($filesystem, $fullPath, $name);
37
38
        $stub = $this->getStub($filesystem);
39
40
        $filesystem->put($fullPath, $stub);
41
42
        $this->info("Component {$name} succesfully created.");
43
    }
44
45
    /**
46
     * Get and return stub.
47
     *
48
     * @param Filesystem $filesystem
49
     *
50
     * @return string
51
     */
52
    protected function getStub(Filesystem $filesystem)
53
    {
54
        $fileName = $this->option('empty') ? 'EmptyComponent' : 'Component';
55
56
        return $filesystem->get(__DIR__.'/../Stubs/'.$fileName.'.vue');
57
    }
58
}
59