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

SimpleGenerator   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
dl 0
loc 33
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 3 1
A __construct() 0 7 2
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
}