Lines
100.00%
5 / 5
Functions and Methods
100.00%
2 / 2
Classes and Traits
100.00%
1 / 1
| Name | Lines | Functions and Methods | CRAP | Classes and Traits | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Gamefile | 100.00% | 5 / 5 | 100.00% | 2 / 2 | 3 | 100.00% | 1 / 1 | |||
| __construct | 100.00% | 4 / 4 | 100.00% | 1 / 1 | 2 | |||||
| __toString | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | |||||
| 1 | <?php | |
| 2 | ||
| 3 | declare(strict_types=1); | |
| 4 | ||
| 5 | namespace Lorekeeper\Core\Asset; | |
| 6 | ||
| 7 | use InvalidArgumentException; | |
| 8 | use Psl\Type; | |
| 9 | use Stringable; | |
| 10 | ||
| 11 | final readonly class Gamefile implements Stringable | |
| 12 | { | |
| 13 | /** @var non-empty-string */ | |
| 14 | public string $value; | |
| 15 | ||
| 16 | public function __construct(string $value) | |
| 17 | { | |
| 18 | $value = Type\non_empty_string()->assert($value); | |
| 19 | ||
| 20 | if (!str_ends_with($value, '.swf')) { | |
| 21 | throw new InvalidArgumentException("Gamefile must end with '.swf', got '{$value}'."); | |
| 22 | } | |
| 23 | ||
| 24 | $this->value = $value; | |
| 25 | } | |
| 26 | ||
| 27 | public function __toString(): string | |
| 28 | { | |
| 29 | return $this->value; | |
| 30 | } | |
| 31 | } |