Passed
Pull Request — master (#8)
by Derek Stephen
10:36
created

PersonCriteria   A

Complexity

Total Complexity 37

Size/Duplication

Total Lines 210
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 37
eloc 61
c 1
b 0
f 0
dl 0
loc 210
ccs 52
cts 52
cp 1
rs 9.44

37 Methods

Rating   Name   Duplication   Size   Complexity  
A getDob() 0 3 1
A setFirstname() 0 3 1
A getFirstname() 0 3 1
A hasId() 0 3 1
A hasOffset() 0 3 1
A getId() 0 3 1
A setCountry() 0 3 1
A setId() 0 3 1
A hasOrderDirection() 0 3 1
A getOrder() 0 3 1
A setDob() 0 3 1
A setMiddlename() 0 3 1
A setOffset() 0 3 1
A setBirthplace() 0 3 1
A getLastname() 0 3 1
A hasCountry() 0 3 1
A hasLastname() 0 3 1
A setAka() 0 3 1
A getAka() 0 3 1
A getOffset() 0 3 1
A getBirthplace() 0 3 1
A hasDob() 0 3 1
A getLimit() 0 3 1
A getOrderDirection() 0 3 1
A hasMiddlename() 0 3 1
A hasFirstname() 0 3 1
A hasLimit() 0 3 1
A getCountry() 0 3 1
A hasBirthplace() 0 3 1
A setOrder() 0 3 1
A hasAka() 0 3 1
A setOrderDirection() 0 3 1
A setPagination() 0 5 1
A getMiddlename() 0 3 1
A setLimit() 0 3 1
A hasOrder() 0 3 1
A setLastname() 0 3 1
1
<?php
2
3
namespace Del\Person\Criteria;
4
5
class PersonCriteria
6
{
7
    const ORDER_ASC = 'ASC';
8
    const ORDER_DESC = 'DESC';
9
    const ORDER_FIRSTNAME = 'firstname';
10
    const ORDER_MIDDLENAME = 'middlename';
11
    const ORDER_LASTNAME = 'state';
12
    const ORDER_AKA = 'aka';
13
    const ORDER_BIRTHPLACE = 'birthplace';
14
    const ORDER_COUNTRY = 'country';
15
    const ORDER_DOB = 'dob';
16
17
    protected ?int $id = null;
18
    protected ?string $firstname = null;
19
    protected ?string $middlename = null;
20
    protected ?string $lastname = null;
21
    protected ?string $aka = null;
22
    protected ?string $birthplace = null;
23
    protected ?string $country = null;
24
    protected ?string $dob = null;
25
    protected ?int $limit = null;
26
    protected ?int $offset = null;
27
    protected ?string $order = null;
28
    protected ?string $orderDirection = null;
29
30
    public function hasOffset(): bool
31
    {
32
        return $this->offset !== null;
33
    }
34
35 1
    public function setOffset(int $offset): void
36
    {
37 1
        $this->offset = $offset;
38
    }
39
40
    public function getOffset(): int
41
    {
42
        return $this->offset;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->offset could return the type null which is incompatible with the type-hinted return integer. Consider adding an additional type-check to rule them out.
Loading history...
43
    }
44 1
45
    public function hasLimit(): bool
46 1
    {
47 1
        return $this->limit !== null;
48
    }
49
50
    public function setLimit(int $limit): void
0 ignored issues
show
Unused Code introduced by
The parameter $limit is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

50
    public function setLimit(/** @scrutinizer ignore-unused */ int $limit): void

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
51
    {
52
        $this->limit = $code;
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $code seems to be never defined.
Loading history...
53 1
    }
54
55 1
    public function getLimit(): int
56
    {
57
        return $this->limit;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->limit could return the type null which is incompatible with the type-hinted return integer. Consider adding an additional type-check to rule them out.
Loading history...
58
    }
59
60
    public function hasOrder(): bool
61 1
    {
62
        return $this->order !== null;
63 1
    }
64
65
    public function setOrder(string $order): void
66
    {
67
        $this->order = $order;
68
    }
69
70 1
    public function getOrder(): string
71
    {
72 1
        return $this->order;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->order could return the type null which is incompatible with the type-hinted return string. Consider adding an additional type-check to rule them out.
Loading history...
73 1
    }
74
75
    public function getOrderDirection(): string
76
    {
77
        return $this->orderDirection;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->orderDirection could return the type null which is incompatible with the type-hinted return string. Consider adding an additional type-check to rule them out.
Loading history...
78
    }
79 1
80
    public function setOrderDirection(string $orderDirection): void
81 1
    {
82
        $this->orderDirection = $orderDirection;
83
    }
84
85
    public function hasOrderDirection(): bool
86
    {
87 1
        return $this->orderDirection !== null;
88
    }
89 1
90
    public function setPagination(int $page, int $limit): void
91
    {
92
        $offset = ($limit * $page) - $limit;
93
        $this->setLimit($limit);
94
        $this->setOffset($offset);
95
    }
96 1
97
    public function getId(): int
98 1
    {
99 1
        return $this->id;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->id could return the type null which is incompatible with the type-hinted return integer. Consider adding an additional type-check to rule them out.
Loading history...
100
    }
101
102
    public function setId(int $id): void
103
    {
104
        $this->id = $id;
105 1
    }
106
107 1
    public function hasId(): bool
108
    {
109
        return $this->id != null;
0 ignored issues
show
Bug Best Practice introduced by
It seems like you are loosely comparing $this->id of type integer|null against null; this is ambiguous if the integer can be zero. Consider using a strict comparison !== instead.
Loading history...
110
    }
111
112
    public function getFirstname(): string
113 1
    {
114
        return $this->firstname;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->firstname could return the type null which is incompatible with the type-hinted return string. Consider adding an additional type-check to rule them out.
Loading history...
115 1
    }
116
117
    public function setFirstname(string $firstname): void
118
    {
119
        $this->firstname = $firstname;
120
    }
121
122 1
    public function hasFirstname(): bool
123
    {
124 1
        return $this->firstname != null;
0 ignored issues
show
Bug introduced by
It seems like you are loosely comparing $this->firstname of type null|string against null; this is ambiguous if the string can be empty. Consider using a strict comparison !== instead.
Loading history...
125 1
    }
126
127
    public function getMiddlename(): string
128
    {
129
        return $this->middlename;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->middlename could return the type null which is incompatible with the type-hinted return string. Consider adding an additional type-check to rule them out.
Loading history...
130
    }
131 1
132
    public function setMiddlename(string $middlename): void
133 1
    {
134
        $this->middlename = $middlename;
135
    }
136
137
    public function hasMiddlename(): bool
138
    {
139
        return $this->middlename != null;
0 ignored issues
show
Bug introduced by
It seems like you are loosely comparing $this->middlename of type null|string against null; this is ambiguous if the string can be empty. Consider using a strict comparison !== instead.
Loading history...
140 1
    }
141
142 1
    public function getLastname(): string
143 1
    {
144 1
        return $this->lastname;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->lastname could return the type null which is incompatible with the type-hinted return string. Consider adding an additional type-check to rule them out.
Loading history...
145 1
    }
146
147
    public function setLastname(string $lastname): void
148
    {
149
        $this->lastname = $lastname;
150 1
    }
151
152 1
    public function hasLastname(): bool
153
    {
154
        return $this->lastname != null;
0 ignored issues
show
Bug introduced by
It seems like you are loosely comparing $this->lastname of type null|string against null; this is ambiguous if the string can be empty. Consider using a strict comparison !== instead.
Loading history...
155
    }
156
157
    public function getAka(): string
158
    {
159 2
        return $this->aka;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->aka could return the type null which is incompatible with the type-hinted return string. Consider adding an additional type-check to rule them out.
Loading history...
160
    }
161 2
162 2
    public function setAka(string $aka): void
163
    {
164
        $this->aka = $aka;
165
    }
166
167
    public function hasAka(): bool
168 1
    {
169
        return $this->aka != null;
0 ignored issues
show
Bug introduced by
It seems like you are loosely comparing $this->aka of type null|string against null; this is ambiguous if the string can be empty. Consider using a strict comparison !== instead.
Loading history...
170 1
    }
171
172
    public function getBirthplace(): string
173
    {
174
        return $this->birthplace;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->birthplace could return the type null which is incompatible with the type-hinted return string. Consider adding an additional type-check to rule them out.
Loading history...
175
    }
176 1
177
    public function setBirthplace(string $birthplace): void
178 1
    {
179
        $this->birthplace = $birthplace;
180
    }
181
182
    public function hasBirthplace(): bool
183
    {
184
        return $this->birthplace != null;
0 ignored issues
show
Bug introduced by
It seems like you are loosely comparing $this->birthplace of type null|string against null; this is ambiguous if the string can be empty. Consider using a strict comparison !== instead.
Loading history...
185 2
    }
186
187 2
    public function getCountry(): string
188 2
    {
189
        return $this->country;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->country could return the type null which is incompatible with the type-hinted return string. Consider adding an additional type-check to rule them out.
Loading history...
190
    }
191
192
    public function setCountry(string $country): void
193
    {
194 1
        $this->country = $country;
195
    }
196 1
197
    public function hasCountry(): bool
198
    {
199
        return $this->country != null;
0 ignored issues
show
Bug introduced by
It seems like you are loosely comparing $this->country of type null|string against null; this is ambiguous if the string can be empty. Consider using a strict comparison !== instead.
Loading history...
200
    }
201
202 1
    public function getDob(): string
203
    {
204 1
        return $this->dob;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->dob could return the type null which is incompatible with the type-hinted return string. Consider adding an additional type-check to rule them out.
Loading history...
205
    }
206
207
    public function setDob(string $dob): void
208
    {
209
        $this->dob = $dob;
210
    }
211 2
212
    public function hasDob(): bool
213 2
    {
214 2
        return $this->dob != null;
0 ignored issues
show
Bug introduced by
It seems like you are loosely comparing $this->dob of type null|string against null; this is ambiguous if the string can be empty. Consider using a strict comparison !== instead.
Loading history...
215
    }
216
}
217