| Conditions | 2 |
| Paths | 2 |
| Total Lines | 8 |
| Code Lines | 4 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 5 |
| CRAP Score | 2 |
| Changes | 0 | ||
| 1 | <?php declare(strict_types=1); |
||
| 7 | 36 | public static function requireFields(array $fields, array $data, string $type) |
|
| 8 | { |
||
| 9 | $missingFields = \array_filter($fields, function (string $field) use ($data) { |
||
| 10 | 36 | return !isset($data[$field]); |
|
| 11 | 36 | }); |
|
| 12 | |||
| 13 | 36 | if (!empty($missingFields)) { |
|
| 14 | 17 | throw new \InvalidArgumentException(\sprintf('Missing fields "%s" in the %s: `%s`.', \implode(', ', $missingFields), $type, \json_encode($data))); |
|
| 15 | } |
||
| 18 |