Completed
Push — master ( f707f5...a08928 )
by Rasmus
02:27
created

Column::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 11
ccs 10
cts 10
cp 1
rs 9.4285
cc 1
eloc 9
nc 1
nop 8
crap 1

How to fix   Many Parameters   

Many Parameters

Methods with many parameters are not only hard to understand, but their parameters also often become inconsistent when you need more, or different data.

There are several approaches to avoid long parameter lists:

1
<?php
2
3
namespace mindplay\sql\model\schema;
4
5
use mindplay\sql\model\Driver;
6
7
/**
8
 * This class represents a Column belonging to a Table.
9
 */
10
class Column
11
{
12
    /**
13
     * @var Table
14
     */
15
    private $table;
16
17
    /**
18
     * @var Driver
19
     */
20
    private $driver;
21
22
    /**
23
     * @var Type
24
     */
25
    private $type;
26
27
    /**
28
     * @var string
29
     */
30
    private $name;
31
32
    /**
33
     * @var string
34
     */
35
    private $alias;
36
37
    /**
38
     * @var bool
39
     */
40
    private $required;
41
42
    /**
43
     * @var mixed
44
     */
45
    private $default;
46
47
    /**
48
     * @var bool
49
     */
50
    private $auto;
51
52
    /**
53
     * @param Driver      $driver
54
     * @param Table       $table parent Table instance
55
     * @param string      $name
56
     * @param Type        $type
57
     * @param string|null $alias
58
     * @param bool        $required
59
     * @param mixed       $default
60
     * @param bool        $auto
61
     */
62 1
    public function __construct(Driver $driver, Table $table, $name, Type $type, $alias, $required, $default, $auto)
63
    {
64 1
        $this->table = $table;
65 1
        $this->driver = $driver;
66 1
        $this->type = $type;
67 1
        $this->name = $name;
68 1
        $this->alias = $alias;
69 1
        $this->required = $required;
70 1
        $this->default = $default;
71 1
        $this->auto = $auto;
72 1
    }
73
74
    /**
75
     * @return Table
76
     */
77 1
    public function getTable()
78
    {
79 1
        return $this->table;
80
    }
81
82
    /**
83
     * @return Type
84
     */
85 1
    public function getType()
86
    {
87 1
        return $this->type;
88
    }
89
90
    /**
91
     * @return string
92
     */
93 1
    public function getName()
94
    {
95 1
        return $this->name;
96
    }
97
98
    /**
99
     * @return string|null
100
     */
101 1
    public function getAlias()
102
    {
103 1
        return $this->alias;
104
    }
105
106
    /**
107
     * @return bool
108
     */
109
    public function isRequired()
110
    {
111
        return $this->required;
112
    }
113
114
    /**
115
     * @return mixed
116
     */
117
    public function getDefault()
118
    {
119
        return $this->default;
120
    }
121
122
    /**
123
     * @return bool
124
     */
125 1
    public function isAuto()
126
    {
127 1
        return $this->auto;
128
    }
129
130
    /**
131
     * @ignore
132
     *
133
     * @return string
134
     */
135 1
    public function __toString()
136
    {
137 1
        return $this->table->__toString() . '.' . $this->driver->quoteName($this->name);
138
    }
139
}
140