Passed
Push — 2.0 ( 21259a...8b13d0 )
by Sébastien
19:00
created

FkExtractor   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Test Coverage

Coverage 20%

Importance

Changes 0
Metric Value
wmc 3
eloc 8
dl 0
loc 35
ccs 2
cts 10
cp 0.2
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A onCheck() 0 2 1
A all() 0 3 1
A onForeignKey() 0 7 1
1
<?php
2
3
namespace Bdf\Prime\Schema\Transformer\Doctrine;
4
5
use Bdf\Prime\Schema\Constraint\CheckInterface;
6
use Bdf\Prime\Schema\Constraint\ConstraintVisitorInterface;
7
use Bdf\Prime\Schema\Constraint\ForeignKeyInterface;
8
use Doctrine\DBAL\Schema\ForeignKeyConstraint;
9
10
/**
11
 * Transform prime column to doctrine column
12
 */
13
final class FkExtractor implements ConstraintVisitorInterface
14
{
15
    /**
16
     * @var ForeignKeyConstraint[]
17
     */
18
    private $fk = [];
19
20
    /**
21
     * {@inheritdoc}
22
     */
23
    public function onForeignKey(ForeignKeyInterface $foreignKey)
24
    {
25
        $this->fk[] = new ForeignKeyConstraint(
26
            $foreignKey->fields(),
27
            $foreignKey->table(),
28
            $foreignKey->referred(),
29
            $foreignKey->name()
30
        );
31
    }
32
33
    /**
34
     * Get the doctrine foreign key constraints
35
     *
36
     * @return ForeignKeyConstraint[]
37
     */
38 1068
    public function all()
39
    {
40 1068
        return $this->fk;
41
    }
42
43
    /**
44
     * {@inheritdoc}
45
     */
46
    public function onCheck(CheckInterface $check)
47
    {
48
    }
49
}
50