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