Conditions | 8 |
Paths | 8 |
Total Lines | 28 |
Code Lines | 14 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
19 | public function validate(array $record, array $topicList): void |
||
20 | { |
||
21 | if (!isset($record['topic'])) { |
||
22 | throw InvalidRecordInSet::missingTopic(); |
||
23 | } |
||
24 | |||
25 | if (!is_string($record['topic'])) { |
||
26 | throw InvalidRecordInSet::topicIsNotString(); |
||
27 | } |
||
28 | |||
29 | if (trim($record['topic']) === '') { |
||
30 | throw InvalidRecordInSet::missingTopic(); |
||
31 | } |
||
32 | |||
33 | if (!isset($topicList[$record['topic']])) { |
||
34 | throw InvalidRecordInSet::nonExististingTopic($record['topic']); |
||
35 | } |
||
36 | |||
37 | if (!isset($record['value'])) { |
||
38 | throw InvalidRecordInSet::missingValue(); |
||
39 | } |
||
40 | |||
41 | if (!is_string($record['value'])) { |
||
42 | throw InvalidRecordInSet::valueIsNotString(); |
||
43 | } |
||
44 | |||
45 | if (trim($record['value']) === '') { |
||
46 | throw InvalidRecordInSet::missingValue(); |
||
47 | } |
||
50 |