ConfigMakeCommand   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 4
dl 0
loc 56
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getStub() 0 4 1
A getPath() 0 10 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Cortex\Foundation\Console\Commands;
6
7
use Illuminate\Console\ConfirmableTrait;
8
use Illuminate\Console\GeneratorCommand;
9
use Cortex\Foundation\Traits\ConsoleMakeModuleCommand;
10
11
class ConfigMakeCommand extends GeneratorCommand
12
{
13
    use ConfirmableTrait;
14
    use ConsoleMakeModuleCommand;
15
16
    /**
17
     * The console command name.
18
     *
19
     * @var string
20
     */
21
    protected $name = 'make:config';
22
23
    /**
24
     * The console command description.
25
     *
26
     * @var string
27
     */
28
    protected $description = 'Create a new config file';
29
30
    /**
31
     * The type of class being generated.
32
     *
33
     * @var string
34
     */
35
    protected $type = 'Config';
36
37
    /**
38
     * Get the stub file for the generator.
39
     *
40
     * @return string
41
     */
42
    protected function getStub(): string
43
    {
44
        return __DIR__.'/../../../resources/stubs/config.stub';
45
    }
46
47
    /**
48
     * Get the destination class path.
49
     *
50
     * @param string $name
51
     *
52
     * @throws \Exception
53
     *
54
     * @return string
55
     */
56
    protected function getPath($name): string
57
    {
58
        $name = str_replace_first($this->rootNamespace(), $this->moduleName().DIRECTORY_SEPARATOR.'config', $name);
0 ignored issues
show
Deprecated Code introduced by
The function str_replace_first() has been deprecated with message: Str::replaceFirst() should be used directly instead. Will be removed in Laravel 6.0.

This function has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead.

Loading history...
59
60
        if (! $this->files->exists($path = $this->laravel['path'].DIRECTORY_SEPARATOR.$this->moduleName())) {
61
            throw new \Exception("Invalid path: {$path}");
62
        }
63
64
        return $this->laravel['path'].DIRECTORY_SEPARATOR.str_replace('\\', DIRECTORY_SEPARATOR, $name).'.php';
65
    }
66
}
67