Conditions | 4 |
Paths | 4 |
Total Lines | 31 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 20 |
Changes | 2 | ||
Bugs | 0 | Features | 2 |
1 | <?php |
||
22 | public function load($locationType, $locationId) { |
||
23 | |||
24 | if(!($unitRows = DBStaticUnit::db_get_unit_list_by_location(0, $locationType, $locationId))) { |
||
25 | return null; |
||
26 | } |
||
27 | |||
28 | $model = \classSupernova::$gc->unitModel; |
||
29 | foreach($unitRows as $dbId => $unitRow) { |
||
|
|||
30 | $unit = $model->fromArray($unitRow); |
||
31 | $this->attach($unit); |
||
32 | if($unit->snId) { |
||
33 | $this->unitBySnId[$unit->snId] = $unit; |
||
34 | } |
||
35 | } |
||
36 | |||
37 | /** |
||
38 | * |
||
39 | * |
||
40 | |||
41 | |||
42 | foreach(unitsInLocation($location) as $unit_row) { |
||
43 | $unit_obj = new V2Unit()->load($unit_row); |
||
44 | $this->attach($unit_obj, $unit_obj->dbId); |
||
45 | } |
||
46 | |||
47 | |||
48 | |||
49 | |||
50 | * |
||
51 | */ |
||
52 | } |
||
53 | |||
55 |
There are different options of fixing this problem.
If you want to be on the safe side, you can add an additional type-check:
If you are sure that the expression is traversable, you might want to add a doc comment cast to improve IDE auto-completion and static analysis:
Mark the issue as a false-positive: Just hover the remove button, in the top-right corner of this issue for more options.