Code Duplication    Length = 15-16 lines in 2 locations

src/DataTypes/Light/PowerTransition.php 1 location

@@ 19-33 (lines=15) @@
16
     * @param int $duration
17
     * @throws InvalidValueException
18
     */
19
    public function __construct(int $level, int $duration)
20
    {
21
        if ($level < 0 || $level > 65535) {
22
            throw new InvalidValueException("Power level {$level} outside allowable range of 0 - 65535");
23
        }
24
25
        if ($duration < UINT32_MIN || $duration > UINT32_MAX) {
26
            throw new InvalidValueException(
27
                "Transition duration {$duration} outside allowable range of " . UINT32_MIN . " - " . UINT32_MAX
28
            );
29
        }
30
31
        $this->level = $level;
32
        $this->duration = $duration;
33
    }
34
35
    public function getLevel(): int
36
    {

src/DataTypes/Service.php 1 location

@@ 19-34 (lines=16) @@
16
     * @param int $port
17
     * @throws InvalidValueException
18
     */
19
    public function __construct(int $typeId, int $port)
20
    {
21
        if ($typeId < 0 || $typeId > 255) {
22
            throw new InvalidValueException("Service type ID {$typeId} outside allowable range of 0 - 255");
23
        }
24
25
        // Protocol spec states this is a uint32 rather than a uint16, so allow any uint32 value at the protocol level
26
        if ($port < UINT32_MIN || $port > UINT32_MAX) {
27
            throw new InvalidValueException(
28
                "Port {$port} outside allowable range of " . UINT32_MIN . " - " . UINT32_MAX
29
            );
30
        }
31
32
        $this->typeId = $typeId;
33
        $this->port = $port;
34
    }
35
36
    public function getTypeId(): int
37
    {