CheckTypeCondition   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 4
dl 0
loc 27
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A canApply() 0 3 1
1
<?php
2
namespace DBFaker\Generators\Conditions;
3
4
use DBFaker\Exceptions\UnsupportedDataTypeException;
5
use Doctrine\DBAL\Schema\Column;
6
use Doctrine\DBAL\Schema\Table;
7
use Doctrine\DBAL\Types\Type;
8
9
class CheckTypeCondition implements ConditionInterface
10
{
11
12
    /**
13
     * @var Type
14
     */
15
    private $type;
16
17
    /**
18
     * CheckTypeCondition constructor.
19
     * @param Type $type : the Type to check
20
     * @throws \DBFaker\Exceptions\UnsupportedDataTypeException
21
     * @throws \Doctrine\DBAL\DBALException
22
     */
23
    public function __construct(Type $type)
24
    {
25
        $this->type = $type;
26
    }
27
28
    /**
29
     * @param Table $table
30
     * @param Column $column
31
     * @return bool : if the Generator will be applied
32
     */
33
    public function canApply(Table $table, Column $column) : bool
34
    {
35
        return $this->type === $column->getType();
36
    }
37
}
38