Completed
Push — master ( adc131...6e9eb4 )
by Kevin
03:32
created

SimpleGenerator::__invoke()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

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