|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Ps2alerts\Api\QueryObjects; |
|
4
|
|
|
|
|
5
|
|
|
class QueryObject |
|
6
|
|
|
{ |
|
7
|
|
|
/** |
|
8
|
|
|
* @var array |
|
9
|
|
|
*/ |
|
10
|
|
|
protected $wheres; |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* @var string |
|
14
|
|
|
*/ |
|
15
|
|
|
protected $orderBy; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* @var string |
|
19
|
|
|
*/ |
|
20
|
|
|
protected $orderByDirection = 'asc'; |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* @var string |
|
24
|
|
|
*/ |
|
25
|
|
|
protected $dimension = 'multi'; |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* Limit of records to bring back |
|
29
|
|
|
* |
|
30
|
|
|
* @var integer |
|
31
|
|
|
*/ |
|
32
|
|
|
protected $limit = null; |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* Place to set special workaround flags |
|
36
|
|
|
* |
|
37
|
|
|
* @var string|array |
|
38
|
|
|
*/ |
|
39
|
|
|
protected $flags; |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* Adds where statements to the object |
|
43
|
|
|
* |
|
44
|
|
|
* @param array $array |
|
45
|
|
|
*/ |
|
46
|
|
|
public function addWhere($array) |
|
47
|
|
|
{ |
|
48
|
|
|
$this->wheres[] = $array; |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* Pulls out the array for the where statements |
|
53
|
|
|
* |
|
54
|
|
|
* @return array |
|
55
|
|
|
*/ |
|
56
|
|
|
public function getWheres() |
|
57
|
|
|
{ |
|
58
|
|
|
return $this->wheres; |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* Set order by column |
|
63
|
|
|
* |
|
64
|
|
|
* @param string $string [description] |
|
65
|
|
|
*/ |
|
66
|
|
|
public function setOrderBy($string) |
|
67
|
|
|
{ |
|
68
|
|
|
$this->orderBy = $string; |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
/** |
|
72
|
|
|
* Get order by column |
|
73
|
|
|
* |
|
74
|
|
|
* @return string |
|
75
|
|
|
*/ |
|
76
|
|
|
public function getOrderBy() |
|
77
|
|
|
{ |
|
78
|
|
|
return $this->orderBy; |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
/** |
|
82
|
|
|
* Set asc or desc |
|
83
|
|
|
* |
|
84
|
|
|
* @param string $string |
|
85
|
|
|
*/ |
|
86
|
|
|
public function setOrderByDirection($string) |
|
87
|
|
|
{ |
|
88
|
|
|
$this->orderByDirection = $string; |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
/** |
|
92
|
|
|
* Gets order by direction |
|
93
|
|
|
* |
|
94
|
|
|
* @return string |
|
95
|
|
|
*/ |
|
96
|
|
|
public function getOrderByDirection() |
|
97
|
|
|
{ |
|
98
|
|
|
return $this->orderByDirection; |
|
99
|
|
|
} |
|
100
|
|
|
|
|
101
|
|
|
/** |
|
102
|
|
|
* Set array dimension level |
|
103
|
|
|
* |
|
104
|
|
|
* @param string $string |
|
105
|
|
|
*/ |
|
106
|
|
|
public function setDimension($string) |
|
107
|
|
|
{ |
|
108
|
|
|
$this->dimension = $string; |
|
109
|
|
|
} |
|
110
|
|
|
|
|
111
|
|
|
/** |
|
112
|
|
|
* Gets array dimension level |
|
113
|
|
|
* |
|
114
|
|
|
* @return string |
|
115
|
|
|
*/ |
|
116
|
|
|
public function getDimension() |
|
117
|
|
|
{ |
|
118
|
|
|
return $this->dimension; |
|
119
|
|
|
} |
|
120
|
|
|
|
|
121
|
|
|
/** |
|
122
|
|
|
* Sets the limit of records to bring back |
|
123
|
|
|
* |
|
124
|
|
|
* @param integer $limit |
|
125
|
|
|
*/ |
|
126
|
|
|
public function setLimit($limit) |
|
127
|
|
|
{ |
|
128
|
|
|
if (is_numeric($limit)) { |
|
129
|
|
|
$this->limit = $limit; |
|
|
|
|
|
|
130
|
|
|
} |
|
131
|
|
|
} |
|
132
|
|
|
|
|
133
|
|
|
/** |
|
134
|
|
|
* Gets the limit of records |
|
135
|
|
|
* |
|
136
|
|
|
* @return integer |
|
137
|
|
|
*/ |
|
138
|
|
|
public function getLimit() |
|
139
|
|
|
{ |
|
140
|
|
|
return $this->limit; |
|
141
|
|
|
} |
|
142
|
|
|
|
|
143
|
|
|
/** |
|
144
|
|
|
* Allows setting of workaround flags |
|
145
|
|
|
* |
|
146
|
|
|
* @param array|string $flags |
|
147
|
|
|
*/ |
|
148
|
|
|
public function setFlags($flags) |
|
149
|
|
|
{ |
|
150
|
|
|
$this->flags = $flags; |
|
151
|
|
|
} |
|
152
|
|
|
|
|
153
|
|
|
/** |
|
154
|
|
|
* Retreives workaround flags |
|
155
|
|
|
* |
|
156
|
|
|
* @return array|string |
|
157
|
|
|
*/ |
|
158
|
|
|
public function getFlags() |
|
159
|
|
|
{ |
|
160
|
|
|
return $this->flags; |
|
161
|
|
|
} |
|
162
|
|
|
} |
|
163
|
|
|
|
Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.
For example, imagine you have a variable
$accountIdthat can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to theidproperty of an instance of theAccountclass. This class holds a proper account, so the id value must no longer be false.Either this assignment is in error or a type check should be added for that assignment.