Lines 100.00% 4 / 4
Functions and Methods 100.00% 1 / 1
Classes and Traits 100.00% 1 / 1
Name Lines Functions and Methods CRAP Classes and Traits
LevelRange 100.00% 4 / 4 100.00% 1 / 1 2 100.00% 1 / 1
 __construct 100.00% 4 / 4 100.00% 1 / 1 2
1<?php
2
3declare(strict_types=1);
4
5namespace Lorekeeper\Core\Progression;
6
7use InvalidArgumentException;
8use Psl\Type;
9
10final readonly class LevelRange
11{
12    /** @var int<0, 100> */
13    public int $minimum;
14
15    /** @var int<0, 100> */
16    public int $maximum;
17
18    public function __construct(int $minimum, int $maximum)
19    {
20        $this->minimum = Type\int_range(min: 0, max: 100)->assert($minimum);
21        $this->maximum = Type\int_range(min: 0, max: 100)->assert($maximum);
22
23        if ($this->minimum > $this->maximum) {
24            throw new InvalidArgumentException("Level range minimum {$minimum} is above maximum {$maximum}.");
25        }
26    }
27}