aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Structure/Types/Limits.php
blob: e2ec343c0fd4800b64696c41df6159a838e0062b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<?php

declare(strict_types=1);

namespace Nsfisis\Waddiwasi\Structure\Types;

final readonly class Limits
{
    /**
     * @param U32 $min
     * @param ?U32 $max
     */
    public function __construct(
        public int $min,
        public ?int $max,
    ) {
    }

    public function isValid(): bool
    {
        return 0 <= $this->min &&
            ($this->max === null || $this->min <= $this->max);
    }
}