Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
3 / 3 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
EnumFaker | |
100.00% |
3 / 3 |
|
100.00% |
2 / 2 |
2 | |
100.00% |
1 / 1 |
supports | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
fakeFor | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 |
1 | <?php |
2 | namespace Apie\Faker\Fakers; |
3 | |
4 | use Apie\Faker\Interfaces\ApieClassFaker; |
5 | use Faker\Generator; |
6 | use ReflectionClass; |
7 | use UnitEnum; |
8 | |
9 | /** @implements ApieClassFaker<UnitEnum> */ |
10 | class EnumFaker implements ApieClassFaker |
11 | { |
12 | public function supports(ReflectionClass $class): bool |
13 | { |
14 | return $class->implementsInterface(UnitEnum::class); |
15 | } |
16 | |
17 | public function fakeFor(Generator $generator, ReflectionClass $class): object |
18 | { |
19 | $className = $class->name; |
20 | return $generator->randomElement($className::cases()); |
21 | } |
22 | } |