Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
4 / 4 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| HasActiveFilter | |
100.00% |
4 / 4 |
|
100.00% |
2 / 2 |
3 | |
100.00% |
1 / 1 |
| getActiveData | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
| requiresActive | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getOptions | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
2 | |||
| 1 | <?php |
| 2 | namespace Apie\IanaValueObjects; |
| 3 | |
| 4 | use Apie\Core\Lists\StringSet; |
| 5 | |
| 6 | trait HasActiveFilter |
| 7 | { |
| 8 | abstract protected static function getActiveData(): array; |
| 9 | private static StringSet $activeOptions; |
| 10 | |
| 11 | protected static function requiresActive(): bool |
| 12 | { |
| 13 | return true; |
| 14 | } |
| 15 | |
| 16 | public static function getOptions(): StringSet |
| 17 | { |
| 18 | if (!isset(static::$activeOptions)) { |
| 19 | static::$activeOptions = new StringSet(array_keys(static::getActiveData())); |
| 20 | } |
| 21 | return static::$activeOptions; |
| 22 | } |
| 23 | } |