SimpleGenerator::__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 SimpleGenerator implements FakeDataGeneratorInterface
8
{
9
10
    /**
11
     * @var string
12
     */
13
    private $fakerProperty;
14
15
    /**
16
     * @var Generator
17
     */
18
    private $faker;
19
20
    /**
21
     * SimpleGenerator constructor.
22
     * @param string $fakerProperty
23
     * @param bool $generateUniqueValues
24
     */
25
    public function __construct(string $fakerProperty, bool $generateUniqueValues = false)
26
    {
27
        $this->faker = Factory::create();
28
        if ($generateUniqueValues) {
29
            $this->faker->unique();
30
        }
31
        $this->fakerProperty = $fakerProperty;
32
    }
33
34
    /**
35
     * @return mixed
36
     */
37
    public function __invoke()
38
    {
39
        return $this->faker->{$this->fakerProperty};
40
    }
41
}
42