Passed
Push — develop ( 3046e8...f3e3d3 )
by Henry
13:14
created

Column::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 38
Code Lines 18

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 18
c 1
b 0
f 0
nc 1
nop 18
dl 0
loc 38
ccs 0
cts 21
cp 0
crap 2
rs 9.6666

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 Divergence\Models\Mapping;
4
5
use Attribute;
6
use BackedEnum;
0 ignored issues
show
Bug introduced by
The type BackedEnum was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
7
8
/**
9
 * @Annotation
10
 * @NamedArgumentConstructor
11
 * @Target({"PROPERTY","ANNOTATION"})
12
 */
13
#[Attribute(Attribute::TARGET_PROPERTY)]
14
final class Column implements MappingAttribute
15
{
16
17
    /**
18
     * @var string|null
19
     * @readonly
20
     */
21
    public $columnName;
22
23
    /**
24
     * @var mixed
25
     * @readonly
26
     */
27
    public $type;
28
29
    /**
30
     * @var int|null
31
     * @readonly
32
     */
33
    public $length;
34
35
    /**
36
     * The precision for a decimal (exact numeric) column (Applies only for decimal column).
37
     *
38
     * @var int|null
39
     * @readonly
40
     */
41
    public $precision = 0;
42
43
    /**
44
     * The scale for a decimal (exact numeric) column (Applies only for decimal column).
45
     *
46
     * @var int|null
47
     * @readonly
48
     */
49
    public $scale = 0;
50
51
    /**
52
     * @var bool
53
     * @readonly
54
     */
55
    public $unique = false;
56
57
    /**
58
     * @var bool
59
     * @readonly
60
     */
61
    public $notnull = true;
62
63
    /**
64
     * @var bool
65
     * @readonly
66
     */
67
    public $autoincrement;
68
69
    /**
70
     * @var bool
71
     * @readonly
72
     */
73
    public $unsigned;
74
75
    /**
76
     * @var bool
77
     * @readonly
78
     */
79
    public $primary;
80
81
    /**
82
     * @var bool
83
     * @readonly
84
     */
85
    public $insertable = true;
86
87
    /**
88
     * @var bool
89
     * @readonly
90
     */
91
    public $updatable = true;
92
93
    /**
94
     * @var string|null
95
     * @readonly
96
     */
97
    public $delimiter = null;
98
99
    /**
100
     * @var array<string,mixed>
101
     * @readonly
102
     */
103
    public $values = [];
104
105
    /**
106
     * @var class-string<BackedEnum>|null
0 ignored issues
show
Documentation Bug introduced by
The doc comment class-string<BackedEnum>|null at position 0 could not be parsed: Unknown type name 'class-string' at position 0 in class-string<BackedEnum>|null.
Loading history...
107
     * @readonly
108
     */
109
    public $enumType = null;
110
111
    /**
112
     * @var array<string,mixed>
113
     * @readonly
114
     */
115
    public $options = [];
116
117
    /**
118
     * @var string|null
119
     * @readonly
120
     */
121
    public $columnDefinition;
122
123
    /**
124
     * @var string|null
125
     * @readonly
126
     * @psalm-var 'NEVER'|'INSERT'|'ALWAYS'|null
127
     * @Enum({"NEVER", "INSERT", "ALWAYS"})
128
     */
129
    public $generated;
130
131
    /**
132
     * @param class-string<BackedEnum>|null $enumType
0 ignored issues
show
Documentation Bug introduced by
The doc comment class-string<BackedEnum>|null at position 0 could not be parsed: Unknown type name 'class-string' at position 0 in class-string<BackedEnum>|null.
Loading history...
133
     * @param array<string,mixed>           $options
134
     * @psalm-param 'NEVER'|'INSERT'|'ALWAYS'|null $generated
135
     */
136
    public function __construct(
137
        ?string $columnName = null,
138
        ?string $type = null,
139
        ?int $length = null,
140
        ?int $precision = null,
141
        ?int $scale = null,
142
        bool $unique = false,
143
        bool $notnull = true,
144
        bool $autoincrement = false,
145
        bool $unsigned = null,
146
        bool $primary = false,
147
        bool $insertable = true,
148
        bool $updatable = true,
149
        string $delimiter = null,
150
        array $values = [],
151
        ?string $enumType = null,
152
        array $options = [],
153
        ?string $columnDefinition = null,
154
        ?string $generated = null
155
    ) {
156
        $this->columnName       = $columnName;
157
        $this->type             = $type;
158
        $this->length           = $length;
159
        $this->precision        = $precision;
160
        $this->scale            = $scale;
161
        $this->unique           = $unique;
162
        $this->notnull          = $notnull;
163
        $this->autoincrement    = $autoincrement;
164
        $this->unsigned         = $unsigned;
165
        $this->primary          = $primary;
166
        $this->insertable       = $insertable;
167
        $this->updatable        = $updatable;
168
        $this->delimiter        = $delimiter;
169
        $this->values           = $values;
170
        $this->enumType         = $enumType;
171
        $this->options          = $options;
172
        $this->columnDefinition = $columnDefinition;
173
        $this->generated        = $generated;
174
    }
175
}