Passed
Pull Request — master (#8)
by Derek Stephen
07:57 queued 06:07
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 76
cts 76
cp 1
rs 9.44

37 Methods

Rating   Name   Duplication   Size   Complexity  
A getDob() 0 3 1
A getId() 0 3 1
A getOrder() 0 3 1
A setOffset() 0 3 1
A hasDob() 0 3 1
A hasFirstname() 0 3 1
A hasLimit() 0 3 1
A getCountry() 0 3 1
A setFirstname() 0 3 1
A getFirstname() 0 3 1
A hasId() 0 3 1
A hasOffset() 0 3 1
A setCountry() 0 3 1
A setId() 0 3 1
A hasOrderDirection() 0 3 1
A setDob() 0 3 1
A setMiddlename() 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 getLimit() 0 3 1
A getOrderDirection() 0 3 1
A hasMiddlename() 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 1
    public function hasOffset(): bool
31
    {
32 1
        return $this->offset !== null;
33
    }
34
35 1
    public function setOffset(int $offset): void
36
    {
37 1
        $this->offset = $offset;
38
    }
39
40 1
    public function getOffset(): int
41
    {
42 1
        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
45 1
    public function hasLimit(): bool
46
    {
47 1
        return $this->limit !== null;
48
    }
49
50 1
    public function setLimit(int $limit): void
51
    {
52 1
        $this->limit = $limit;
53
    }
54
55 1
    public function getLimit(): int
56
    {
57 1
        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 1
    public function hasOrder(): bool
61
    {
62 1
        return $this->order !== null;
63
    }
64
65 1
    public function setOrder(string $order): void
66
    {
67 1
        $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
    }
74
75 1
    public function getOrderDirection(): string
76
    {
77 1
        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
80 1
    public function setOrderDirection(string $orderDirection): void
81
    {
82 1
        $this->orderDirection = $orderDirection;
83
    }
84
85 1
    public function hasOrderDirection(): bool
86
    {
87 1
        return $this->orderDirection !== null;
88
    }
89
90 1
    public function setPagination(int $page, int $limit): void
91
    {
92 1
        $offset = ($limit * $page) - $limit;
93 1
        $this->setLimit($limit);
94 1
        $this->setOffset($offset);
95
    }
96
97 1
    public function getId(): int
98
    {
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 2
    public function setId(int $id): void
103
    {
104 2
        $this->id = $id;
105
    }
106
107 1
    public function hasId(): bool
108
    {
109 1
        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 1
    public function getFirstname(): string
113
    {
114 1
        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
    }
116
117 2
    public function setFirstname(string $firstname): void
118
    {
119 2
        $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
    }
126
127 1
    public function getMiddlename(): string
128
    {
129 1
        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
132 2
    public function setMiddlename(string $middlename): void
133
    {
134 2
        $this->middlename = $middlename;
135
    }
136
137 1
    public function hasMiddlename(): bool
138
    {
139 1
        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
    }
141
142 1
    public function getLastname(): string
143
    {
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
    }
146
147 2
    public function setLastname(string $lastname): void
148
    {
149 2
        $this->lastname = $lastname;
150
    }
151
152 1
    public function hasLastname(): bool
153
    {
154 1
        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 1
    public function getAka(): string
158
    {
159 1
        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
162 2
    public function setAka(string $aka): void
163
    {
164 2
        $this->aka = $aka;
165
    }
166
167 1
    public function hasAka(): bool
168
    {
169 1
        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
    }
171
172 1
    public function getBirthplace(): string
173
    {
174 1
        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
177 2
    public function setBirthplace(string $birthplace): void
178
    {
179 2
        $this->birthplace = $birthplace;
180
    }
181
182 1
    public function hasBirthplace(): bool
183
    {
184 1
        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
    }
186
187 1
    public function getCountry(): string
188
    {
189 1
        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 2
    public function setCountry(string $country): void
193
    {
194 2
        $this->country = $country;
195
    }
196
197 1
    public function hasCountry(): bool
198
    {
199 1
        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 2
    public function setDob(string $dob): void
208
    {
209 2
        $this->dob = $dob;
210
    }
211
212 1
    public function hasDob(): bool
213
    {
214 1
        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