Passed
Push — master ( 9bb89d...1caa12 )
by Gustavo
02:12
created

Command::getModelArgument()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 15
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
cc 2
eloc 7
c 1
b 1
f 0
nc 2
nop 0
dl 0
loc 15
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
        $modelClass = $this->argument('model') ?? '';
19
20
        $modelClass = (string) $modelClass;
21
22
        if (! class_exists($modelClass)) {
23
            $message = "Model `{$modelClass}` not found.";
24
25
            $this->error($message);
26
27
            throw new Exception($message);
28
        }
29
30
        return $modelClass;
31
    }
32
}
33