VueGeneratorsCommand   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 4
dl 0
loc 32
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A createPath() 0 12 2
A checkFileExists() 0 6 2
1
<?php
2
3
namespace VueGenerators\Commands;
4
5
use VueGenerators\Paths;
6
use Illuminate\Console\Command;
7
use Illuminate\Filesystem\Filesystem;
8
use VueGenerators\Exceptions\ResourceAlreadyExists;
9
10
class VueGeneratorsCommand extends Command
11
{
12
    use Paths;
13
14
    /**
15
     * Create path for file.
16
     *
17
     * @param Filesystem $filesystem
18
     * @param string     $type       File type.
19
     *
20
     * @return string
21
     */
22
    protected function createPath(Filesystem $filesystem, $type)
23
    {
24
        $customPath = $this->option('path');
25
26
        $defaultPath = config("vue-generators.paths.{$type}s");
27
28
        $path = $customPath !== null ? $customPath : $defaultPath;
29
30
        $this->buildPathFromArray($path, $filesystem);
31
32
        return $path;
33
    }
34
35
    protected function checkFileExists(Filesystem $filesystem, $path, $name)
36
    {
37
        if ($filesystem->exists($path)) {
38
            throw ResourceAlreadyExists::fileExists($name);
39
        }
40
    }
41
}
42