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