Lines 100.00% 2 / 2
Functions and Methods 100.00% 2 / 2
Classes and Traits 100.00% 1 / 1
Name Lines Functions and Methods CRAP Classes and Traits
Level 100.00% 2 / 2 100.00% 2 / 2 2 100.00% 1 / 1
 __construct 100.00% 1 / 1 100.00% 1 / 1 1
 maximum n/a 0 / 0 n/a 0 / 0 0
 __toString 100.00% 1 / 1 100.00% 1 / 1 1
1<?php
2
3declare(strict_types=1);
4
5namespace Lorekeeper\Core\Game\Level;
6
7use Psl\Type;
8use Stringable;
9
10abstract readonly class Level implements Stringable
11{
12    /** @var positive-int */
13    public int $value;
14
15    final public function __construct(int $value)
16    {
17        $this->value = Type\int_range(min: 1, max: static::maximum())->assert($value);
18    }
19
20    /** @return positive-int */
21    abstract protected static function maximum(): int;
22
23    final public function __toString(): string
24    {
25        return (string) $this->value;
26    }
27}