Total Complexity | 4 |
Total Lines | 36 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | <?php |
||
12 | final class TopicName { |
||
13 | /** |
||
14 | * |
||
15 | * @var string |
||
16 | */ |
||
17 | private $topicName; |
||
18 | |||
19 | /** |
||
20 | * Topic name constructor. |
||
21 | * |
||
22 | * @param string $topicName |
||
23 | * |
||
24 | * @throws \OutOfBoundsException |
||
25 | * @throws \InvalidArgumentException |
||
26 | */ |
||
27 | 6 | public function __construct(string $topicName) |
|
28 | { |
||
29 | 6 | if ($topicName === '') { |
|
30 | 1 | throw new \InvalidArgumentException('Topic name must be at least 1 character long'); |
|
31 | } |
||
32 | |||
33 | 5 | if (\strlen($topicName) > 65535) { |
|
34 | 1 | throw new \OutOfBoundsException('Topic name can not exceed 65535 bytes'); |
|
35 | } |
||
36 | |||
37 | 4 | $this->topicName = $topicName; |
|
38 | 4 | } |
|
39 | |||
40 | /** |
||
41 | * Gets the current QoS level |
||
42 | * |
||
43 | * @return int |
||
44 | */ |
||
45 | 4 | public function getTopicName(): string |
|
48 | } |
||
49 | } |
||
50 |