| Conditions | 5 |
| Paths | 4 |
| Total Lines | 15 |
| Code Lines | 7 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 8 |
| CRAP Score | 5 |
| Changes | 0 | ||
| 1 | <?php |
||
| 11 | 5 | public function getMessage($value, ?array $options) |
|
| 12 | { |
||
| 13 | 5 | if ($options === null || !isset($options['haystack'])) { |
|
| 14 | 2 | throw new \InvalidArgumentException('Haystack parameter must be passed in options'); |
|
| 15 | } |
||
| 16 | |||
| 17 | 3 | if (\count($options['haystack']) === 0) { |
|
| 18 | 1 | throw new \InvalidArgumentException('Haystack parameter must not be an empty array'); |
|
| 19 | } |
||
| 20 | |||
| 21 | 2 | if (!\in_array((string)$value, $options['haystack'], true)) { |
|
| 22 | 1 | return sprintf('Option \'%s\' not found in passed haystack', $value); |
|
| 23 | } |
||
| 24 | |||
| 25 | 1 | return null; |
|
| 26 | } |
||
| 28 |