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 | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| NonNegativeInteger | 100.00% | 2 / 2 | 100.00% | 2 / 2 | 2 | 100.00% | 1 / 1 | |||
| __construct | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | |||||
| __toString | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | |||||
| 1 | <?php | |
| 2 | ||
| 3 | declare(strict_types=1); | |
| 4 | ||
| 5 | namespace Lorekeeper\Core\Support; | |
| 6 | ||
| 7 | use Psl\Type; | |
| 8 | use Stringable; | |
| 9 | ||
| 10 | abstract readonly class NonNegativeInteger implements Stringable | |
| 11 | { | |
| 12 | /** @var non-negative-int */ | |
| 13 | public int $value; | |
| 14 | ||
| 15 | final public function __construct(int $value) | |
| 16 | { | |
| 17 | $this->value = Type\uint()->assert($value); | |
| 18 | } | |
| 19 | ||
| 20 | final public function __toString(): string | |
| 21 | { | |
| 22 | return (string) $this->value; | |
| 23 | } | |
| 24 | } |