thecodingmachine /
DBFaker
| 1 | <?php |
||
| 2 | namespace DBFaker\Generators; |
||
| 3 | |||
| 4 | use Faker\Factory; |
||
| 5 | use Faker\Generator; |
||
| 6 | |||
| 7 | class DateIntervalGenerator implements FakeDataGeneratorInterface |
||
| 8 | { |
||
| 9 | |||
| 10 | /** |
||
| 11 | * @var Generator |
||
| 12 | */ |
||
| 13 | private $faker; |
||
| 14 | |||
| 15 | /** |
||
| 16 | * ComplexObjectGenerator constructor. |
||
| 17 | * @param bool $generateUniqueValues |
||
| 18 | */ |
||
| 19 | public function __construct(bool $generateUniqueValues = false) |
||
| 20 | { |
||
| 21 | $this->faker = Factory::create(); |
||
| 22 | if ($generateUniqueValues) { |
||
| 23 | $this->faker->unique(); |
||
| 24 | } |
||
| 25 | } |
||
| 26 | |||
| 27 | /** |
||
| 28 | * @return \DateInterval |
||
| 29 | */ |
||
| 30 | public function __invoke() : \DateInterval |
||
| 31 | { |
||
| 32 | return $this->faker->dateTime->diff($this->faker->dateTime); |
||
|
0 ignored issues
–
show
Bug
Best Practice
introduced
by
Loading history...
|
|||
| 33 | } |
||
| 34 | } |
||
| 35 |