Priority   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
dl 0
loc 19
c 1
b 0
f 0
rs 10
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A fromInt() 0 3 1
A __construct() 0 7 3
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