SimpleGeneratorFactory   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 5
dl 0
loc 21
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A create() 0 4 1
1
<?php
2
namespace DBFaker\Generators;
3
4
use DBFaker\Helpers\SchemaHelper;
5
use Doctrine\DBAL\Schema\Column;
6
use Doctrine\DBAL\Schema\Table;
7
8
class SimpleGeneratorFactory implements FakeDataGeneratorFactoryInterface
9
{
10
11
    /**
12
     * @var string
13
     */
14
    private $callback;
15
16
    /**
17
     * SimpleGeneratorFactory constructor.
18
     * @param string $fakerCallback
19
     */
20
    public function __construct(string $fakerCallback)
21
    {
22
        $this->callback = $fakerCallback;
23
    }
24
25
    public function create(Table $table, Column $column, SchemaHelper $schemaHelper) : FakeDataGeneratorInterface
26
    {
27
        $unique = $schemaHelper->isColumnPartOfUniqueIndex($table, $column);
28
        return new SimpleGenerator($this->callback, $unique);
29
    }
30
}
31