| Conditions | 3 |
| Paths | 2 |
| Total Lines | 15 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 1 |
| CRAP Score | 3 |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php namespace Arcanedev\Support; |
||
| 25 | public function unique($key = null, $strict = false) |
||
| 26 | 8 | { |
|
| 27 | if (is_null($key)) |
||
| 28 | return new static(array_unique($this->items, SORT_REGULAR)); |
||
| 29 | |||
| 30 | $key = $this->valueRetriever($key); |
||
|
|
|||
| 31 | $exists = []; |
||
| 32 | |||
| 33 | return $this->reject(function ($item) use ($key, $strict, &$exists) { |
||
| 34 | if (in_array($id = $key($item), $exists, $strict)) { |
||
| 35 | return true; |
||
| 36 | } |
||
| 37 | $exists[] = $id; |
||
| 38 | }); |
||
| 39 | } |
||
| 40 | |||
| 65 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: