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 | namespace Dkd\PhpCmis; |
||
3 | |||
4 | /* |
||
5 | * This file is part of php-cmis-client. |
||
6 | * |
||
7 | * (c) Sascha Egerer <[email protected]> |
||
8 | * |
||
9 | * For the full copyright and license information, please view the LICENSE |
||
10 | * file that was distributed with this source code. |
||
11 | */ |
||
12 | |||
13 | use Dkd\PhpCmis\Enum\IncludeRelationships; |
||
14 | |||
15 | /** |
||
16 | * OperationContext implementation |
||
17 | */ |
||
18 | class OperationContext implements OperationContextInterface |
||
19 | { |
||
20 | const PROPERTIES_WILDCARD = '*'; |
||
21 | |||
22 | /** |
||
23 | * @var string[] |
||
24 | */ |
||
25 | private $filter = []; |
||
26 | |||
27 | /** |
||
28 | * @var boolean |
||
29 | */ |
||
30 | private $loadSecondaryTypeProperties = false; |
||
31 | |||
32 | /** |
||
33 | * @var boolean |
||
34 | */ |
||
35 | private $includeAcls = false; |
||
36 | |||
37 | /** |
||
38 | * @var boolean |
||
39 | */ |
||
40 | private $includeAllowableActions = true; |
||
41 | |||
42 | /** |
||
43 | * @var boolean |
||
44 | */ |
||
45 | private $includePolicies = false; |
||
46 | |||
47 | /** |
||
48 | * @var IncludeRelationships |
||
49 | */ |
||
50 | private $includeRelationships = null; |
||
51 | |||
52 | /** |
||
53 | * @var string[] |
||
54 | */ |
||
55 | private $renditionFilter = []; |
||
56 | |||
57 | /** |
||
58 | * @var boolean |
||
59 | */ |
||
60 | private $includePathSegments = true; |
||
61 | |||
62 | /** |
||
63 | * @var string |
||
64 | */ |
||
65 | private $orderBy = null; |
||
66 | |||
67 | /** |
||
68 | * @var boolean |
||
69 | */ |
||
70 | private $cacheEnabled = false; |
||
71 | |||
72 | /** |
||
73 | * @var integer |
||
74 | */ |
||
75 | private $maxItemsPerPage = 100; |
||
76 | |||
77 | /** |
||
78 | * Creates new Operation Context |
||
79 | */ |
||
80 | 61 | public function __construct() |
|
81 | { |
||
82 | 61 | $this->setRenditionFilter([]); |
|
83 | 61 | $this->includeRelationships = IncludeRelationships::cast(IncludeRelationships::NONE); |
|
84 | 61 | } |
|
85 | |||
86 | /** |
||
87 | * {@inheritdoc} |
||
88 | */ |
||
89 | 1 | public function isCacheEnabled() |
|
90 | { |
||
91 | 1 | return $this->cacheEnabled; |
|
92 | } |
||
93 | |||
94 | /** |
||
95 | * {@inheritdoc} |
||
96 | */ |
||
97 | 9 | public function setCacheEnabled($cacheEnabled) |
|
98 | { |
||
99 | 9 | $this->cacheEnabled = (boolean) $cacheEnabled; |
|
100 | 9 | return $this; |
|
101 | } |
||
102 | |||
103 | /** |
||
104 | * {@inheritdoc} |
||
105 | */ |
||
106 | 1 | public function getCacheKey() |
|
107 | { |
||
108 | 1 | $cacheKey = $this->isIncludeAcls() ? '1' : '0'; |
|
109 | 1 | $cacheKey .= $this->isIncludeAllowableActions() ? '1' : '0'; |
|
110 | 1 | $cacheKey .= $this->isIncludePolicies() ? '1' : '0'; |
|
111 | 1 | $cacheKey .= $this->isIncludePathSegments() ? '1' : '0'; |
|
112 | 1 | $cacheKey .= '|'; |
|
113 | 1 | $cacheKey .= $this->getQueryFilterString(); |
|
114 | 1 | $cacheKey .= '|'; |
|
115 | 1 | $cacheKey .= (string) $this->getIncludeRelationships(); |
|
116 | 1 | $cacheKey .= '|'; |
|
117 | 1 | $cacheKey .= $this->getRenditionFilterString(); |
|
118 | |||
119 | 1 | return $cacheKey; |
|
120 | } |
||
121 | |||
122 | /** |
||
123 | * {@inheritdoc} |
||
124 | */ |
||
125 | 1 | public function getFilter() |
|
126 | { |
||
127 | 1 | return $this->filter; |
|
128 | } |
||
129 | |||
130 | /** |
||
131 | * {@inheritdoc} |
||
132 | */ |
||
133 | 8 | View Code Duplication | public function setFilter(array $propertyFilters) |
0 ignored issues
–
show
|
|||
134 | { |
||
135 | 8 | $filters = []; |
|
136 | 8 | foreach ($propertyFilters as $filter) { |
|
137 | 8 | $filter = trim((string) $filter); |
|
138 | 8 | if ($filter === '') { |
|
139 | 1 | continue; |
|
140 | } |
||
141 | |||
142 | 8 | if (self::PROPERTIES_WILDCARD === $filter) { |
|
143 | 1 | $filters[] = self::PROPERTIES_WILDCARD; |
|
144 | 1 | break; |
|
145 | } |
||
146 | |||
147 | 8 | if (stripos($filter, ',') !== false) { |
|
148 | 1 | throw new \InvalidArgumentException('Filter must not contain a comma!'); |
|
149 | } |
||
150 | |||
151 | 8 | $filters[] = $filter; |
|
152 | 8 | } |
|
153 | |||
154 | 7 | $this->filter = $filters; |
|
155 | |||
156 | 7 | return $this; |
|
157 | } |
||
158 | |||
159 | /** |
||
160 | * {@inheritdoc} |
||
161 | */ |
||
162 | 2 | public function isIncludeAcls() |
|
163 | { |
||
164 | 2 | return $this->includeAcls; |
|
165 | } |
||
166 | |||
167 | /** |
||
168 | * {@inheritdoc} |
||
169 | */ |
||
170 | 2 | public function setIncludeAcls($includeAcls) |
|
171 | { |
||
172 | 2 | $this->includeAcls = $includeAcls; |
|
173 | |||
174 | 2 | return $this; |
|
175 | } |
||
176 | |||
177 | /** |
||
178 | * {@inheritdoc} |
||
179 | */ |
||
180 | 2 | public function isIncludeAllowableActions() |
|
181 | { |
||
182 | 2 | return $this->includeAllowableActions; |
|
183 | } |
||
184 | |||
185 | /** |
||
186 | * {@inheritdoc} |
||
187 | */ |
||
188 | 2 | public function setIncludeAllowableActions($includeAllowableActions) |
|
189 | { |
||
190 | 2 | $this->includeAllowableActions = $includeAllowableActions; |
|
191 | 2 | return $this; |
|
192 | } |
||
193 | |||
194 | /** |
||
195 | * {@inheritdoc} |
||
196 | */ |
||
197 | 2 | public function isIncludePathSegments() |
|
198 | { |
||
199 | 2 | return $this->includePathSegments; |
|
200 | } |
||
201 | |||
202 | /** |
||
203 | * {@inheritdoc} |
||
204 | */ |
||
205 | 2 | public function setIncludePathSegments($includePathSegments) |
|
206 | { |
||
207 | 2 | $this->includePathSegments = $includePathSegments; |
|
208 | 2 | return $this; |
|
209 | } |
||
210 | |||
211 | /** |
||
212 | * {@inheritdoc} |
||
213 | */ |
||
214 | 2 | public function isIncludePolicies() |
|
215 | { |
||
216 | 2 | return $this->includePolicies; |
|
217 | } |
||
218 | |||
219 | /** |
||
220 | * {@inheritdoc} |
||
221 | */ |
||
222 | 2 | public function setIncludePolicies($includePolicies) |
|
223 | { |
||
224 | 2 | $this->includePolicies = $includePolicies; |
|
225 | 2 | return $this; |
|
226 | } |
||
227 | |||
228 | /** |
||
229 | * {@inheritdoc} |
||
230 | */ |
||
231 | 2 | public function getIncludeRelationships() |
|
232 | { |
||
233 | 2 | return $this->includeRelationships; |
|
234 | } |
||
235 | |||
236 | /** |
||
237 | * {@inheritdoc} |
||
238 | */ |
||
239 | 2 | public function setIncludeRelationships(IncludeRelationships $includeRelationships) |
|
240 | { |
||
241 | 2 | $this->includeRelationships = $includeRelationships; |
|
242 | |||
243 | 2 | return $this; |
|
244 | } |
||
245 | |||
246 | /** |
||
247 | * {@inheritdoc} |
||
248 | */ |
||
249 | 3 | public function loadSecondaryTypeProperties() |
|
250 | { |
||
251 | 3 | return $this->loadSecondaryTypeProperties; |
|
252 | } |
||
253 | |||
254 | /** |
||
255 | * {@inheritdoc} |
||
256 | */ |
||
257 | 2 | public function setLoadSecondaryTypeProperties($loadSecondaryTypeProperties) |
|
258 | { |
||
259 | 2 | $this->loadSecondaryTypeProperties = (boolean) $loadSecondaryTypeProperties; |
|
260 | |||
261 | 2 | return $this; |
|
262 | } |
||
263 | |||
264 | /** |
||
265 | * {@inheritdoc} |
||
266 | */ |
||
267 | 1 | public function getMaxItemsPerPage() |
|
268 | { |
||
269 | 1 | return $this->maxItemsPerPage; |
|
270 | } |
||
271 | |||
272 | /** |
||
273 | * {@inheritdoc} |
||
274 | */ |
||
275 | 2 | public function setMaxItemsPerPage($maxItemsPerPage) |
|
276 | { |
||
277 | 2 | if ((int) $maxItemsPerPage < 1) { |
|
278 | 1 | throw new \InvalidArgumentException('itemsPerPage must be > 0!'); |
|
279 | } |
||
280 | 1 | $this->maxItemsPerPage = (int) $maxItemsPerPage; |
|
281 | |||
282 | 1 | return $this; |
|
283 | } |
||
284 | |||
285 | /** |
||
286 | * {@inheritdoc} |
||
287 | */ |
||
288 | 1 | public function getOrderBy() |
|
289 | { |
||
290 | 1 | return $this->orderBy; |
|
291 | } |
||
292 | |||
293 | /** |
||
294 | * {@inheritdoc} |
||
295 | */ |
||
296 | 1 | public function setOrderBy($orderBy) |
|
297 | { |
||
298 | 1 | $this->orderBy = $orderBy; |
|
299 | |||
300 | 1 | return $this; |
|
301 | } |
||
302 | |||
303 | /** |
||
304 | * {@inheritdoc} |
||
305 | */ |
||
306 | 1 | public function getRenditionFilter() |
|
307 | { |
||
308 | 1 | return $this->renditionFilter; |
|
309 | } |
||
310 | |||
311 | /** |
||
312 | * {@inheritdoc} |
||
313 | */ |
||
314 | 61 | View Code Duplication | public function setRenditionFilter(array $renditionFilter) |
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. ![]() |
|||
315 | { |
||
316 | 61 | $filters = []; |
|
317 | 61 | foreach ($renditionFilter as $filter) { |
|
318 | 6 | $filter = trim((string) $filter); |
|
319 | 6 | if ($filter === '') { |
|
320 | 1 | continue; |
|
321 | } |
||
322 | |||
323 | 6 | if (stripos($filter, ',') !== false) { |
|
324 | 1 | throw new \InvalidArgumentException('Rendition must not contain a comma!'); |
|
325 | } |
||
326 | |||
327 | 6 | $filters[] = $filter; |
|
328 | 61 | } |
|
329 | |||
330 | 61 | if (count($filters) === 0) { |
|
331 | 61 | $filters[] = Constants::RENDITION_NONE; |
|
332 | 61 | } |
|
333 | |||
334 | 61 | $this->renditionFilter = $filters; |
|
335 | |||
336 | 61 | return $this; |
|
337 | } |
||
338 | |||
339 | |||
340 | /** |
||
341 | * {@inheritdoc} |
||
342 | */ |
||
343 | 4 | public function getQueryFilterString() |
|
344 | { |
||
345 | 4 | if (count($this->filter) === 0) { |
|
346 | 2 | return null; |
|
347 | } |
||
348 | |||
349 | 3 | if (array_search(self::PROPERTIES_WILDCARD, $this->filter)) { |
|
350 | 1 | return self::PROPERTIES_WILDCARD; |
|
351 | } |
||
352 | |||
353 | 2 | $filters = $this->filter; |
|
354 | 2 | $filters[] = PropertyIds::OBJECT_ID; |
|
355 | 2 | $filters[] = PropertyIds::BASE_TYPE_ID; |
|
356 | 2 | $filters[] = PropertyIds::OBJECT_TYPE_ID; |
|
357 | |||
358 | 2 | if ($this->loadSecondaryTypeProperties()) { |
|
359 | 1 | $filters[] = PropertyIds::SECONDARY_OBJECT_TYPE_IDS; |
|
360 | 1 | } |
|
361 | |||
362 | 2 | return implode(',', array_unique($filters)); |
|
363 | } |
||
364 | |||
365 | /** |
||
366 | * {@inheritdoc} |
||
367 | */ |
||
368 | 3 | public function getRenditionFilterString() |
|
369 | { |
||
370 | 3 | if (count($this->renditionFilter) === 0) { |
|
371 | 1 | return null; |
|
372 | } |
||
373 | |||
374 | 2 | return implode(',', $this->renditionFilter); |
|
375 | } |
||
376 | |||
377 | /** |
||
378 | * {@inheritdoc} |
||
379 | */ |
||
380 | 1 | public function setFilterString($propertyFilter) |
|
381 | { |
||
382 | 1 | if (empty($propertyFilter)) { |
|
383 | 1 | $this->setFilter([]); |
|
384 | 1 | } else { |
|
385 | 1 | $this->setFilter(explode(',', $propertyFilter)); |
|
386 | } |
||
387 | |||
388 | 1 | return $this; |
|
389 | } |
||
390 | |||
391 | /** |
||
392 | * {@inheritdoc} |
||
393 | */ |
||
394 | 1 | public function setRenditionFilterString($renditionFilter) |
|
395 | { |
||
396 | 1 | if (empty($renditionFilter)) { |
|
397 | 1 | $this->setRenditionFilter([]); |
|
398 | 1 | } else { |
|
399 | 1 | $this->setRenditionFilter(explode(',', $renditionFilter)); |
|
400 | } |
||
401 | |||
402 | 1 | return $this; |
|
403 | } |
||
404 | } |
||
405 |
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.