| Conditions | 3 |
| Paths | 2 |
| Total Lines | 11 |
| Code Lines | 5 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 5 |
| CRAP Score | 3 |
| Changes | 0 | ||
| 1 | <?php |
||
| 34 | 14 | public function __invoke($subject, $field, array $array) |
|
| 35 | { |
||
| 36 | 14 | $value = $subject->$field; |
|
| 37 | 14 | if (! is_string($value) && ! is_int($value)) { |
|
| 38 | // array_key_exists errors on non-string non-int keys. |
||
| 39 | 3 | return false; |
|
| 40 | } |
||
| 41 | // using array_keys() converts string numeric keys to integers, which |
||
| 42 | // is *not* the behavior we want. |
||
| 43 | 11 | return array_key_exists($subject->$field, $array); |
|
| 44 | } |
||
| 45 | } |
||
| 46 |