Passed
Push — feature/collation ( 3b40b8...35613b )
by Kit Loong
64:11
created

Column::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 22
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 10
c 1
b 0
f 0
nc 1
nop 10
dl 0
loc 22
rs 9.9332

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 KitLoong\MigrationsGenerator\Schema\SQLSrv;
4
5
class Column
6
{
7
    /** @var string */
8
    private $name;
9
10
    /** @var string */
11
    private $type;
12
13
    /** @var int */
14
    private $length = 0;
15
16
    /** @var bool */
17
    private $notnull;
18
19
    /** @var string|null */
20
    private $default;
21
22
    /** @var int */
23
    private $scale = 0;
24
25
    /** @var int */
26
    private $precision = 0;
27
28
    /** @var bool */
29
    private $autoincrement = false;
30
31
    /** @var string|null */
32
    private $collation;
33
34
    /** @var string|null */
35
    private $comment;
36
37
    /**
38
     * Column constructor.
39
     * @param  string  $name
40
     * @param  string  $type
41
     * @param  int  $length
42
     * @param  bool  $notnull
43
     * @param  int  $scale
44
     * @param  int  $precision
45
     * @param  bool  $autoincrement
46
     * @param  string|null  $default
47
     * @param  string|null  $collation
48
     * @param  string|null  $comment
49
     */
50
    public function __construct(
51
        string $name,
52
        string $type,
53
        int $length,
54
        bool $notnull,
55
        int $scale,
56
        int $precision,
57
        bool $autoincrement,
58
        ?string $default,
59
        ?string $collation,
60
        ?string $comment
61
    ) {
62
        $this->name = $name;
63
        $this->type = $type;
64
        $this->length = $length;
65
        $this->notnull = $notnull;
66
        $this->default = $default;
67
        $this->scale = $scale;
68
        $this->precision = $precision;
69
        $this->autoincrement = $autoincrement;
70
        $this->collation = $collation;
71
        $this->comment = $comment;
72
    }
73
74
    /**
75
     * @return string
76
     */
77
    public function getName(): string
78
    {
79
        return $this->name;
80
    }
81
82
    /**
83
     * @return string
84
     */
85
    public function getType(): string
86
    {
87
        return $this->type;
88
    }
89
90
    /**
91
     * @return int
92
     */
93
    public function getLength(): int
94
    {
95
        return $this->length;
96
    }
97
98
    /**
99
     * @return bool
100
     */
101
    public function isNotnull(): bool
102
    {
103
        return $this->notnull;
104
    }
105
106
    /**
107
     * @return string|null
108
     */
109
    public function getDefault(): ?string
110
    {
111
        return $this->default;
112
    }
113
114
    /**
115
     * @return int
116
     */
117
    public function getScale(): int
118
    {
119
        return $this->scale;
120
    }
121
122
    /**
123
     * @return int
124
     */
125
    public function getPrecision(): int
126
    {
127
        return $this->precision;
128
    }
129
130
    /**
131
     * @return bool
132
     */
133
    public function isAutoincrement(): bool
134
    {
135
        return $this->autoincrement;
136
    }
137
138
    /**
139
     * @return string|null
140
     */
141
    public function getCollation(): ?string
142
    {
143
        return $this->collation;
144
    }
145
146
    /**
147
     * @return string|null
148
     */
149
    public function getComment(): ?string
150
    {
151
        return $this->comment;
152
    }
153
}
154