Failed Conditions
Push — refactor/improve-static-analys... ( 8da3ef...a7b39f )
by Bas
09:53
created

ModelMakeCommand::resolveStubPath()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 5
ccs 0
cts 0
cp 0
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 1
crap 6
1
<?php
2
3
declare(strict_types=1);
4
5
namespace LaravelFreelancerNL\Aranguent\Console;
6
7
use Illuminate\Foundation\Console\ModelMakeCommand as IlluminateModelMakeCommand;
8
9
class ModelMakeCommand extends IlluminateModelMakeCommand
10
{
11
    /**
12
     * The console command name.
13
     *
14
     * @var string
15
     */
16
    protected $name = 'aranguent:model';
17
18
    /**
19
     * Get the stub file for the generator.
20
     *
21 1
     * @return string
22
     */
23 1
    protected function getStub()
24
    {
25
        return $this->option('pivot')
26
            ? $this->resolveStubPath('/../../stubs/pivot.model.stub')
27 1
            : $this->resolveStubPath('/../../stubs/model.stub');
28
    }
29
30
    /**
31
     * Resolve the fully-qualified path to the stub.
32
     *
33
     * This method is an exact copy of the original to keep the functionality but reroute __DIR__
34
     *
35
     * @param  string  $stub
36
     * @return string
37
     */
38
    protected function resolveStubPath($stub)
39
    {
40
        return file_exists($customPath = $this->laravel->basePath(trim($stub, '/')))
41
            ? $customPath
42
            : __DIR__ . $stub;
43
    }
44
}
45