| Conditions | 4 |
| Paths | 4 |
| Total Lines | 16 |
| Code Lines | 7 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 8 |
| CRAP Score | 4 |
| Changes | 0 | ||
| 1 | <?php |
||
| 15 | 68 | protected function generalRulesCheck(string $topic): bool |
|
| 16 | { |
||
| 17 | 68 | if ($topic === '') { |
|
| 18 | 1 | throw new \InvalidArgumentException('Topics must be at least 1 character long'); |
|
| 19 | } |
||
| 20 | |||
| 21 | // UTF-8 topic names and filters must not be more than 65535 bytes in size |
||
| 22 | 67 | if (\strlen($topic) > 65535) { |
|
| 23 | 1 | throw new \OutOfBoundsException('Topics can not exceed 65535 bytes in size'); |
|
| 24 | } |
||
| 25 | |||
| 26 | 66 | if (strpos($topic, \chr("\n")) !== false) { |
|
|
|
|||
| 27 | 1 | throw new \InvalidArgumentException('Topics can not contain the termination character'); |
|
| 28 | } |
||
| 29 | |||
| 30 | 65 | return true; |
|
| 31 | } |
||
| 33 |