Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
75.00% |
3 / 4 |
|
50.00% |
1 / 2 |
CRAP | |
0.00% |
0 / 1 |
| ActiveHttpStatus | |
75.00% |
3 / 4 |
|
50.00% |
1 / 2 |
3.14 | |
0.00% |
0 / 1 |
| getOptions | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
2 | |||
| requiresActive | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | namespace Apie\IanaValueObjects\HttpStatus; |
| 3 | |
| 4 | use Apie\Core\Lists\StringSet; |
| 5 | use Apie\Core\ValueObjects\Interfaces\LimitedOptionsInterface; |
| 6 | use Apie\Core\ValueObjects\Interfaces\StringValueObjectInterface; |
| 7 | use Apie\IanaValueObjects\StaticDataValueObject; |
| 8 | |
| 9 | /** |
| 10 | * All HTTP status codes registered in the IANA HTTP Status Codes Registry. |
| 11 | * |
| 12 | * @see https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml |
| 13 | * |
| 14 | * Only active/assigned HTTP status codes can be used. |
| 15 | */ |
| 16 | final class ActiveHttpStatus implements StringValueObjectInterface, LimitedOptionsInterface |
| 17 | { |
| 18 | use IsHttpStatus; |
| 19 | use StaticDataValueObject; |
| 20 | |
| 21 | private static StringSet $activeOptions; |
| 22 | |
| 23 | public static function getOptions(): StringSet |
| 24 | { |
| 25 | if (!isset(static::$activeOptions)) { |
| 26 | static::$activeOptions = new StringSet(array_map('strval', array_keys(static::getActiveData()))); |
| 27 | } |
| 28 | return static::$activeOptions; |
| 29 | } |
| 30 | |
| 31 | protected static function requiresActive(): bool |
| 32 | { |
| 33 | return true; |
| 34 | } |
| 35 | } |