Priority::fromInt()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
nc 1
nop 1
dl 0
loc 3
c 1
b 0
f 0
cc 1
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Th3Mouk\ReactiveEventDispatcher;
6
7
/**
8
 * @psalm-immutable
9
 */
10
final class Priority
11
{
12
    private const MIN_VALUE = -1024;
13
    private const MAX_VALUE = 1024;
14
15
    public int $value;
16
17
    private function __construct(int $value)
18
    {
19
        if ($value < self::MIN_VALUE || $value > self::MAX_VALUE) {
20
            throw new \InvalidArgumentException('Priority value must be between ' . self::MIN_VALUE . ' and ' . self::MAX_VALUE);
21
        }
22
23
        $this->value = $value;
24
    }
25
26
    public static function fromInt(int $value): self
27
    {
28
        return new self($value);
29
    }
30
}
31