This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace T4webInfrastructure; |
||
4 | |||
5 | use T4webDomainInterface\Infrastructure\CriteriaInterface; |
||
6 | |||
7 | class InMemoryCriteria implements CriteriaInterface |
||
8 | { |
||
9 | /** |
||
10 | * @var string |
||
11 | */ |
||
12 | protected $entityName; |
||
13 | |||
14 | /** |
||
15 | * @var array |
||
16 | */ |
||
17 | protected $callbacks; |
||
18 | |||
19 | /** |
||
20 | * @param string $entityName |
||
21 | */ |
||
22 | public function __construct($entityName) |
||
23 | { |
||
24 | $this->entityName = $entityName; |
||
25 | $this->callbacks = []; |
||
26 | } |
||
27 | |||
28 | /** |
||
29 | * @return mixed |
||
30 | */ |
||
31 | public function &getQuery() |
||
32 | { |
||
33 | return $this->callbacks; |
||
34 | } |
||
35 | |||
36 | /** |
||
37 | * @return string |
||
38 | */ |
||
39 | public function getEntityName() |
||
40 | { |
||
41 | return $this->entityName; |
||
42 | } |
||
43 | |||
44 | /** |
||
45 | * @param string $entityName |
||
46 | * @return CriteriaInterface |
||
47 | */ |
||
48 | public function relation($entityName) |
||
49 | { |
||
50 | // not implemented |
||
51 | return $this; |
||
52 | } |
||
53 | |||
54 | /** |
||
55 | * @param string $attribute |
||
56 | * @param bool|int|float|string $value |
||
57 | * @return $this |
||
58 | */ |
||
59 | public function equalTo($attribute, $value) |
||
60 | { |
||
61 | $this->callbacks[] = function(array $data) use ($attribute, $value) { |
||
62 | if (!array_key_exists($attribute, $data)) { |
||
63 | return false; |
||
64 | } |
||
65 | |||
66 | if ($data[$attribute] == $value) { |
||
67 | return true; |
||
68 | } |
||
69 | |||
70 | return false; |
||
71 | }; |
||
72 | |||
73 | return $this; |
||
74 | } |
||
75 | |||
76 | /** |
||
77 | * @param string $attribute |
||
78 | * @param bool|int|float|string $value |
||
79 | * @return $this |
||
80 | */ |
||
81 | public function notEqualTo($attribute, $value) |
||
82 | { |
||
83 | $this->callbacks[] = function(array $data) use ($attribute, $value) { |
||
84 | if (!array_key_exists($attribute, $data)) { |
||
85 | return false; |
||
86 | } |
||
87 | |||
88 | if ($data[$attribute] != $value) { |
||
89 | return true; |
||
90 | } |
||
91 | |||
92 | return false; |
||
93 | }; |
||
94 | |||
95 | return $this; |
||
96 | } |
||
97 | |||
98 | /** |
||
99 | * @param string $attribute |
||
100 | * @param int|float $value |
||
101 | * @return $this |
||
102 | */ |
||
103 | public function lessThan($attribute, $value) |
||
104 | { |
||
105 | $this->callbacks[] = function(array $data) use ($attribute, $value) { |
||
106 | if (!array_key_exists($attribute, $data)) { |
||
107 | return false; |
||
108 | } |
||
109 | |||
110 | if ($data[$attribute] < $value) { |
||
111 | return true; |
||
112 | } |
||
113 | |||
114 | return false; |
||
115 | }; |
||
116 | |||
117 | return $this; |
||
118 | } |
||
119 | |||
120 | /** |
||
121 | * @param string $attribute |
||
122 | * @param int|float $value |
||
123 | * @return $this |
||
124 | */ |
||
125 | public function greaterThan($attribute, $value) |
||
126 | { |
||
127 | $this->callbacks[] = function(array $data) use ($attribute, $value) { |
||
128 | if (!array_key_exists($attribute, $data)) { |
||
129 | return false; |
||
130 | } |
||
131 | |||
132 | if ($data[$attribute] > $value) { |
||
133 | return true; |
||
134 | } |
||
135 | |||
136 | return false; |
||
137 | }; |
||
138 | |||
139 | return $this; |
||
140 | } |
||
141 | |||
142 | /** |
||
143 | * @param string $attribute |
||
144 | * @param int|float $value |
||
145 | * @return $this |
||
146 | */ |
||
147 | public function greaterThanOrEqualTo($attribute, $value) |
||
148 | { |
||
149 | $this->callbacks[] = function(array $data) use ($attribute, $value) { |
||
150 | if (!array_key_exists($attribute, $data)) { |
||
151 | return false; |
||
152 | } |
||
153 | |||
154 | if ($data[$attribute] >= $value) { |
||
155 | return true; |
||
156 | } |
||
157 | |||
158 | return false; |
||
159 | }; |
||
160 | |||
161 | return $this; |
||
162 | } |
||
163 | |||
164 | /** |
||
165 | * @param string $attribute |
||
166 | * @param int|float $value |
||
167 | * @return $this |
||
168 | */ |
||
169 | public function lessThanOrEqualTo($attribute, $value) |
||
170 | { |
||
171 | $this->callbacks[] = function(array $data) use ($attribute, $value) { |
||
172 | if (!array_key_exists($attribute, $data)) { |
||
173 | return false; |
||
174 | } |
||
175 | |||
176 | if ($data[$attribute] <= $value) { |
||
177 | return true; |
||
178 | } |
||
179 | |||
180 | return false; |
||
181 | }; |
||
182 | |||
183 | return $this; |
||
184 | } |
||
185 | |||
186 | /** |
||
187 | * @param string $attribute |
||
188 | * @param int|float $value |
||
189 | * @return $this |
||
190 | */ |
||
191 | View Code Duplication | public function like($attribute, $value) |
|
0 ignored issues
–
show
|
|||
192 | { |
||
193 | $this->callbacks[] = function(array $data) use ($attribute, $value) { |
||
194 | if (!array_key_exists($attribute, $data)) { |
||
195 | return false; |
||
196 | } |
||
197 | |||
198 | if (strpos($data[$attribute], $value) !== false) { |
||
199 | return true; |
||
200 | } |
||
201 | |||
202 | return false; |
||
203 | }; |
||
204 | |||
205 | return $this; |
||
206 | } |
||
207 | |||
208 | /** |
||
209 | * @param string $attribute |
||
210 | * @return $this |
||
211 | */ |
||
212 | public function isNull($attribute) |
||
213 | { |
||
214 | $this->callbacks[] = function(array $data) use ($attribute) { |
||
215 | if (!array_key_exists($attribute, $data)) { |
||
216 | return false; |
||
217 | } |
||
218 | |||
219 | if (is_null($data[$attribute])) { |
||
220 | return true; |
||
221 | } |
||
222 | |||
223 | return false; |
||
224 | }; |
||
225 | |||
226 | return $this; |
||
227 | } |
||
228 | |||
229 | /** |
||
230 | * @param string $attribute |
||
231 | * @return $this |
||
232 | */ |
||
233 | public function isNotNull($attribute) |
||
234 | { |
||
235 | $this->callbacks[] = function(array $data) use ($attribute) { |
||
236 | if (!array_key_exists($attribute, $data)) { |
||
237 | return false; |
||
238 | } |
||
239 | |||
240 | if (!is_null($data[$attribute])) { |
||
241 | return true; |
||
242 | } |
||
243 | |||
244 | return false; |
||
245 | }; |
||
246 | |||
247 | return $this; |
||
248 | } |
||
249 | |||
250 | /** |
||
251 | * @param string $attribute |
||
252 | * @param array $values |
||
253 | * @return $this |
||
254 | */ |
||
255 | View Code Duplication | public function in($attribute, array $values) |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository.
Loading history...
|
|||
256 | { |
||
257 | $this->callbacks[] = function(array $data) use ($attribute, $values) { |
||
258 | if (!array_key_exists($attribute, $data)) { |
||
259 | return false; |
||
260 | } |
||
261 | |||
262 | if (in_array($data[$attribute], $values)) { |
||
263 | return true; |
||
264 | } |
||
265 | |||
266 | return false; |
||
267 | }; |
||
268 | |||
269 | return $this; |
||
270 | } |
||
271 | |||
272 | /** |
||
273 | * @param string $attribute |
||
274 | * @param array $values |
||
275 | * @return $this |
||
276 | */ |
||
277 | public function notIn($attribute, array $values) |
||
278 | { |
||
279 | $this->callbacks[] = function(array $data) use ($attribute, $values) { |
||
280 | if (!array_key_exists($attribute, $data)) { |
||
281 | return false; |
||
282 | } |
||
283 | |||
284 | if (!in_array($data[$attribute], $values)) { |
||
285 | return true; |
||
286 | } |
||
287 | |||
288 | return false; |
||
289 | }; |
||
290 | |||
291 | return $this; |
||
292 | } |
||
293 | |||
294 | /** |
||
295 | * @param string $attribute |
||
296 | * @param int|float|string $minValue |
||
297 | * @param int|float|string $maxValue |
||
298 | * @return $this |
||
299 | */ |
||
300 | public function between($attribute, $minValue, $maxValue) |
||
301 | { |
||
302 | $this->callbacks[] = function(array $data) use ($attribute, $minValue, $maxValue) { |
||
303 | if (!array_key_exists($attribute, $data)) { |
||
304 | return false; |
||
305 | } |
||
306 | |||
307 | if ($data[$attribute] >= $minValue && $data[$attribute] <= $maxValue) { |
||
308 | return true; |
||
309 | } |
||
310 | |||
311 | return false; |
||
312 | }; |
||
313 | |||
314 | return $this; |
||
315 | } |
||
316 | |||
317 | /** |
||
318 | * @param string $attribute |
||
319 | * @return $this |
||
320 | */ |
||
321 | public function order($attribute) |
||
322 | { |
||
323 | // not implemented |
||
324 | return $this; |
||
325 | } |
||
326 | |||
327 | /** |
||
328 | * @param int $limit |
||
329 | * @return $this |
||
330 | */ |
||
331 | public function limit($limit) |
||
332 | { |
||
333 | // not implemented |
||
334 | return $this; |
||
335 | } |
||
336 | |||
337 | /** |
||
338 | * @param int $offset |
||
339 | * @return $this |
||
340 | */ |
||
341 | public function offset($offset) |
||
342 | { |
||
343 | // not implemented |
||
344 | return $this; |
||
345 | } |
||
346 | |||
347 | /** |
||
348 | * @param $attribute |
||
349 | * @return string |
||
350 | */ |
||
351 | public function getField($attribute) |
||
352 | { |
||
353 | return $attribute; |
||
354 | } |
||
355 | } |
||
356 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.