Code Coverage |
||||||||||||||||
Lines |
Branches |
Paths |
Functions and Methods |
Classes and Traits |
||||||||||||
| Total | |
100.00% |
6 / 6 |
|
100.00% |
6 / 6 |
|
100.00% |
4 / 4 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| GrammaticalRoleType | |
100.00% |
6 / 6 |
|
100.00% |
6 / 6 |
|
100.00% |
4 / 4 |
|
100.00% |
2 / 2 |
5 | |
100.00% |
1 / 1 |
| fromClass | |
100.00% |
5 / 5 |
|
100.00% |
5 / 5 |
|
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
4 | |||
| fromString | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace App\Enum; |
| 4 | |
| 5 | use App\Entity\Qualifier; |
| 6 | use App\Entity\Subject; |
| 7 | |
| 8 | /** |
| 9 | * @author Wilhelm Zwertvaegher |
| 10 | */ |
| 11 | enum GrammaticalRoleType: string implements Enum |
| 12 | { |
| 13 | case SUBJECT = 'subject'; |
| 14 | case QUALIFIER = 'qualifier'; |
| 15 | |
| 16 | /** |
| 17 | * @param class-string $className |
| 18 | */ |
| 19 | public static function fromClass(string $className): GrammaticalRoleType |
| 20 | { |
| 21 | return match ($className) { |
| 22 | Subject::class => self::SUBJECT, |
| 23 | Qualifier::class => self::QUALIFIER, |
| 24 | default => throw new \InvalidArgumentException('Unknown class: '.$className), |
| 25 | }; |
| 26 | } |
| 27 | |
| 28 | public static function fromString(string $value): Enum |
| 29 | { |
| 30 | return self::from($value); |
| 31 | } |
| 32 | } |