ComplexObjectGeneratorFactory   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 7
dl 0
loc 32
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A create() 0 4 1
A __construct() 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
use Faker\Generator;
8
9
class ComplexObjectGeneratorFactory implements FakeDataGeneratorFactoryInterface
10
{
11
    /**
12
     * @var int|null
13
     */
14
    private $depth;
15
    /**
16
     * @var bool
17
     */
18
    private $toArray;
19
20
    /**
21
     * ComplexObjectGenerator constructor.
22
     * @param int|null $depth
23
     * @param bool $toArray
24
     */
25
    public function __construct(int $depth = null, bool $toArray = true)
26
    {
27
        $this->depth = $depth;
28
        $this->toArray = $toArray;
29
    }
30
31
    /**
32
     * @param Table $table
33
     * @param Column $column
34
     * @param SchemaHelper $schemaHelper
35
     * @return FakeDataGeneratorInterface
36
     */
37
    public function create(Table $table, Column $column, SchemaHelper $schemaHelper): FakeDataGeneratorInterface
38
    {
39
        $unique = $schemaHelper->isColumnPartOfUniqueIndex($table, $column);
40
        return new ComplexObjectGenerator($column, $this->depth, $this->toArray, $unique);
41
    }
42
}
43