Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
EnumFaker
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
2 / 2
2
100.00% covered (success)
100.00%
1 / 1
 supports
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 fakeFor
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2namespace Apie\Faker\Fakers;
3
4use Apie\Faker\Interfaces\ApieClassFaker;
5use Faker\Generator;
6use ReflectionClass;
7use UnitEnum;
8
9/** @implements ApieClassFaker<UnitEnum> */
10class 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}