Passed
Branch feature-dbal (46f2dd)
by Thomas
03:08
created

Column   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 70
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 6
lcom 0
cbo 0
dl 0
loc 70
ccs 19
cts 19
cp 1
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A factory() 0 7 1
A getName() 0 4 1
A getType() 0 4 1
A hasDefault() 0 4 1
A isNullable() 0 4 1
1
<?php
2
3
namespace ORM\Dbal;
4
5
class Column
6
{
7
    /** @var string */
8
    protected $name;
9
10
    /** @var Type */
11
    protected $type;
12
13
    /** @var bool */
14
    protected $hasDefault;
15
16
    /** @var bool */
17
    protected $isNullable;
18
19
    /**
20
     * Column constructor.
21
     *
22
     * @param string $name
23
     * @param Type   $type
24
     * @param bool   $hasDefault
25
     * @param bool   $isNullable
26
     */
27 85
    public function __construct($name, Type $type, $hasDefault, $isNullable)
28
    {
29 85
        $this->name = $name;
30 85
        $this->type = $type;
31 85
        $this->hasDefault = $hasDefault;
32 85
        $this->isNullable = $isNullable;
33 85
    }
34
35 85
    public static function factory($columnDefinition, $type)
36
    {
37 85
        $name = $columnDefinition['column_name'];
38 85
        $hasDefault = $columnDefinition['column_default'] !== null;
39 85
        $isNullable = $columnDefinition['is_nullable'];
40 85
        return new static($name, $type, $hasDefault, $isNullable);
41
    }
42
43
    /**
44
     * @return string
45
     */
46 3
    public function getName()
47
    {
48 3
        return $this->name;
49
    }
50
51
    /**
52
     * @return Type
53
     */
54 66
    public function getType()
55
    {
56 66
        return $this->type;
57
    }
58
59
    /**
60
     * @return bool
61
     */
62 10
    public function hasDefault()
63
    {
64 10
        return $this->hasDefault;
65
    }
66
67
    /**
68
     * @return bool
69
     */
70 6
    public function isNullable()
71
    {
72 6
        return $this->isNullable;
73
    }
74
}
75