SimpleGenerator   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 8
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
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