| Conditions | 3 |
| Paths | 4 |
| Total Lines | 16 |
| Code Lines | 8 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 10 |
| CRAP Score | 3 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 39 | 1 | public function delete(Index $index, $id, $uid = false) |
|
| 40 | { |
||
| 41 | 1 | $this->search->match((int) $id, 'xref_id'); |
|
| 42 | |||
| 43 | 1 | if ($uid) { |
|
| 44 | 1 | $this->search->where(base64_encode($uid), 'uid'); |
|
| 45 | 1 | } |
|
| 46 | |||
| 47 | 1 | foreach ($this->search->hits(false) as $hit) { |
|
|
|
|||
| 48 | 1 | $index->get()->delete($hit); |
|
| 49 | 1 | } |
|
| 50 | |||
| 51 | 1 | $index->get()->commit(); |
|
| 52 | |||
| 53 | 1 | return $this; |
|
| 54 | } |
||
| 55 | } |
||
| 56 |
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.