Passed
Push — Generators ( 4d090d...b2c8db )
by Roy
05:49 queued 14s
created

BaseGeneratorCommand::getClassName()   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 4
cp 0
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 1
crap 6
1
<?php
2
3
namespace LaravelModulize\Console\Commands;
4
5
use Illuminate\Filesystem\Filesystem;
6
use Illuminate\Console\GeneratorCommand;
7
use LaravelModulize\Contracts\ModulizerRepositoryInterface;
8
9
abstract class BaseGeneratorCommand extends GeneratorCommand
10
{
11
    /**
12
     * Instance of the repository
13
     *
14
     * @var \LaravelModulize\Contracts\ModulizerRepositoryInterface
15
     */
16
    protected $repository;
17
18
    protected $module;
19
    protected $modulePath;
20
21
    /**
22
     * Create a new command instance.
23
     *
24
     * @param \LaravelModulize\Contracts\ModulizerRepositoryInterface $repository
25
     * @return void
26
     */
27
    public function __construct(Filesystem $files, ModulizerRepositoryInterface $repository)
28
    {
29
        parent::__construct($files);
30
31
        $this->repository = $repository;
32
    }
33
34
    /**
35
     * Execute the console command.
36
     *
37
     * @return mixed
38
     */
39
    public function handle()
40
    {
41
        $this->module = $this->argument('module');
42
        $this->modulePath = $this->repository->getModulePath($this->module);
0 ignored issues
show
Bug introduced by
It seems like $this->module can also be of type null and string[]; however, parameter $module of LaravelModulize\Contract...erface::getModulePath() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

42
        $this->modulePath = $this->repository->getModulePath(/** @scrutinizer ignore-type */ $this->module);
Loading history...
43
44
        if (!$this->repository->filesExist($this->modulePath)) {
45
            $this->call('modulize:make:module', [
46
                'module' => $this->module,
47
            ]);
48
        }
49
50
        parent::handle();
51
    }
52
}
53