| Conditions | 3 |
| Paths | 2 |
| Total Lines | 15 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 10 |
| CRAP Score | 3 |
| Changes | 0 | ||
| 1 | <?php namespace Arcanedev\Support; |
||
| 25 | 27 | public function unique($key = null, $strict = false) |
|
| 26 | { |
||
| 27 | 27 | if (is_null($key)) |
|
| 28 | 15 | return new static(array_unique($this->items, SORT_REGULAR)); |
|
| 29 | |||
| 30 | 18 | $key = $this->valueRetriever($key); |
|
|
|
|||
| 31 | 18 | $exists = []; |
|
| 32 | |||
| 33 | 18 | return $this->reject(function ($item) use ($key, $strict, &$exists) { |
|
| 34 | 18 | if (in_array($id = $key($item), $exists, $strict)) { |
|
| 35 | 18 | return true; |
|
| 36 | } |
||
| 37 | 18 | $exists[] = $id; |
|
| 38 | 18 | }); |
|
| 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: