DateIntervalGenerator::__invoke()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
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
The expression return $this->faker->dat...$this->faker->dateTime) could return the type false which is incompatible with the type-hinted return DateInterval. Consider adding an additional type-check to rule them out.
Loading history...
33
    }
34
}
35