Passed
Pull Request — master (#28)
by Gustavo
03:00
created

Command::getModelArgument()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 13
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 6
c 0
b 0
f 0
nc 2
nop 0
dl 0
loc 13
rs 10
1
<?php
2
3
namespace Gurgentil\LaravelEloquentSequencer\Console\Commands;
4
5
use Exception;
6
use Illuminate\Console\Command as IlluminateCommand;
7
8
abstract class Command extends IlluminateCommand
9
{
10
    /**
11
     * Get model argument.
12
     *
13
     * @return string
14
     * @throws Exception
15
     */
16
    protected function getModelArgument(): string
17
    {
18
        $class = $this->argument('model');
19
20
        if (! class_exists($class)) {
0 ignored issues
show
Bug introduced by
It seems like $class can also be of type string[]; however, parameter $class_name of class_exists() 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

20
        if (! class_exists(/** @scrutinizer ignore-type */ $class)) {
Loading history...
21
            $message = "Class `{$class}` not found.";
22
23
            $this->error($message);
24
25
            throw new Exception($message);
26
        }
27
28
        return $class;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $class could return the type null|string[] which is incompatible with the type-hinted return string. Consider adding an additional type-check to rule them out.
Loading history...
29
    }
30
}
31