VueGeneratorsCommand::checkFileExists()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 3
dl 0
loc 6
rs 10
c 0
b 0
f 0
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