Conditions | 5 |
Paths | 7 |
Total Lines | 28 |
Code Lines | 14 |
Lines | 0 |
Ratio | 0 % |
Tests | 15 |
CRAP Score | 5 |
Changes | 0 |
1 | <?php |
||
38 | 7 | public function handle(Migrator $migrator) |
|
39 | { |
||
40 | 7 | if (!$this->confirmToProceed()) { |
|
41 | 1 | return; |
|
42 | } |
||
43 | |||
44 | 6 | $seed = $this->argument('name') ?: $migrator->defaultSeed(); |
|
45 | |||
46 | 6 | if (!$seed) { |
|
47 | 1 | $this->error('Default seed is not defined.'); |
|
48 | |||
49 | 1 | return; |
|
50 | } |
||
51 | |||
52 | 5 | $class = $migrator->seedClass($seed); |
|
|
|||
53 | |||
54 | 5 | if (!$class) { |
|
55 | 2 | $this->error("Seed '$seed' is not defined."); |
|
56 | |||
57 | 2 | return; |
|
58 | } |
||
59 | |||
60 | 3 | $this->infoSeedRun($seed, $class); |
|
61 | |||
62 | 3 | $seeder = new $class(); |
|
63 | |||
64 | 3 | $seeder->setCommand($this)->run(); |
|
65 | 3 | } |
|
66 | } |
||
67 |
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.