SimpleGeneratorFactory::__construct()   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 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