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