Conditions | 82 |
Total Lines | 242 |
Code Lines | 141 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
268 | public function toObject(\stdClass $jsonString, bool $isOrQuery = false) |
||
269 | { |
||
270 | $query = new TaskQueryImpl(); |
||
271 | if ($isOrQuery) { |
||
272 | $query->setOrQueryActive(); |
||
273 | } |
||
274 | $json = $jsonString; |
||
275 | if (property_exists($json, self::OR_QUERIES)) { |
||
276 | foreach (JsonUtil::getArray($json, self::OR_QUERIES) as $jsonElement) { |
||
277 | $query->addOrQuery($this->toObject(JsonUtil::getObject($jsonElement), true)); |
||
278 | } |
||
279 | } |
||
280 | if (property_exists($json, self::TASK_ID)) { |
||
281 | $query->taskId(JsonUtil::getString($json, self::TASK_ID)); |
||
282 | } |
||
283 | if (property_exists($json, self::TASK_ID_IN)) { |
||
284 | $query->taskIdIn(JsonUtil::getArray($json, self::TASK_ID_IN)); |
||
285 | } |
||
286 | if (property_exists($json, self::NAME)) { |
||
287 | $query->taskName(JsonUtil::getString($json, self::NAME)); |
||
288 | } |
||
289 | if (property_exists($json, self::NAME_NOT_EQUAL)) { |
||
290 | $query->taskNameNotEqual(JsonUtil::getString($json, self::NAME_NOT_EQUAL)); |
||
291 | } |
||
292 | if (property_exists($json, self::NAME_LIKE)) { |
||
293 | $query->taskNameLike(JsonUtil::getString($json, self::NAME_LIKE)); |
||
294 | } |
||
295 | if (property_exists($json, self::NAME_NOT_LIKE)) { |
||
296 | $query->taskNameNotLike(JsonUtil::getString($json, self::NAME_NOT_LIKE)); |
||
297 | } |
||
298 | if (property_exists($json, self::DESCRIPTION)) { |
||
299 | $query->taskDescription(JsonUtil::getString($json, self::DESCRIPTION)); |
||
300 | } |
||
301 | if (property_exists($json, self::DESCRIPTION_LIKE)) { |
||
302 | $query->taskDescriptionLike(JsonUtil::getString($json, self::DESCRIPTION_LIKE)); |
||
303 | } |
||
304 | if (property_exists($json, self::PRIORITY)) { |
||
305 | $query->taskPriority(JsonUtil::getInt($json, self::PRIORITY)); |
||
306 | } |
||
307 | if (property_exists($json, self::MIN_PRIORITY)) { |
||
308 | $query->taskMinPriority(JsonUtil::getInt($json, self::MIN_PRIORITY)); |
||
309 | } |
||
310 | if (property_exists($json, self::MAX_PRIORITY)) { |
||
311 | $query->taskMaxPriority(JsonUtil::getInt($json, self::MAX_PRIORITY)); |
||
312 | } |
||
313 | if (property_exists($json, self::ASSIGNEE)) { |
||
314 | $query->taskAssignee(JsonUtil::getString($json, self::ASSIGNEE)); |
||
315 | } |
||
316 | if (property_exists($json, self::ASSIGNEE_LIKE)) { |
||
317 | $query->taskAssigneeLike(JsonUtil::getString($json, self::ASSIGNEE_LIKE)); |
||
318 | } |
||
319 | if (property_exists($json, self::ASSIGNEE_IN)) { |
||
320 | $query->taskAssigneeIn(JsonUtil::getArray($json, self::ASSIGNEE_IN)); |
||
321 | } |
||
322 | if (property_exists($json, self::ASSIGNEE_NOT_IN)) { |
||
323 | $query->taskAssigneeNotIn(JsonUtil::getArray($json, self::ASSIGNEE_NOT_IN)); |
||
324 | } |
||
325 | if (property_exists($json, self::INVOLVED_USER)) { |
||
326 | $query->taskInvolvedUser(JsonUtil::getString($json, self::INVOLVED_USER)); |
||
327 | } |
||
328 | if (property_exists($json, self::OWNER)) { |
||
329 | $query->taskOwner(JsonUtil::getString($json, self::OWNER)); |
||
330 | } |
||
331 | if (property_exists($json, self::ASSIGNED) && JsonUtil::getBoolean($json, self::ASSIGNED)) { |
||
332 | $query->taskAssigned(); |
||
333 | } |
||
334 | if (property_exists($json, self::UNASSIGNED) && JsonUtil::getBoolean($json, self::UNASSIGNED)) { |
||
335 | $query->taskUnassigned(); |
||
336 | } |
||
337 | if (property_exists($json, self::DELEGATION_STATE)) { |
||
338 | $query->taskDelegationState(constant("DelegationState::" . JsonUtil::getString($json, self::DELEGATION_STATE))); |
||
339 | } |
||
340 | if (property_exists($json, self::CANDIDATE_USER)) { |
||
341 | $query->taskCandidateUser(JsonUtil::getString($json, self::CANDIDATE_USER)); |
||
342 | } |
||
343 | if (property_exists($json, self::CANDIDATE_GROUP)) { |
||
344 | $query->taskCandidateGroup(JsonUtil::getString($json, self::CANDIDATE_GROUP)); |
||
345 | } |
||
346 | if (property_exists($json, self::CANDIDATE_GROUPS) && !property_exists($json, self::CANDIDATE_USER) && !property_exists($json, self::CANDIDATE_GROUP)) { |
||
347 | $query->taskCandidateGroupIn(JsonUtil::getArray($json, self::CANDIDATE_GROUPS)); |
||
348 | } |
||
349 | if (property_exists($json, self::WITH_CANDIDATE_GROUPS) && JsonUtil::getBoolean($json, self::WITH_CANDIDATE_GROUPS)) { |
||
350 | $query->withCandidateGroups(); |
||
351 | } |
||
352 | if (property_exists($json, self::WITHOUT_CANDIDATE_GROUPS) && JsonUtil::getBoolean($json, self::WITHOUT_CANDIDATE_GROUPS)) { |
||
353 | $query->withoutCandidateGroups(); |
||
354 | } |
||
355 | if (property_exists($json, self::WITH_CANDIDATE_USERS) && JsonUtil::getBoolean($json, self::WITH_CANDIDATE_USERS)) { |
||
356 | $query->withCandidateUsers(); |
||
357 | } |
||
358 | if (property_exists($json, self::WITHOUT_CANDIDATE_USERS) && JsonUtil::getBoolean($json, self::WITHOUT_CANDIDATE_USERS)) { |
||
359 | $query->withoutCandidateUsers(); |
||
360 | } |
||
361 | if (property_exists($json, self::INCLUDE_ASSIGNED_TASKS) && JsonUtil::getBoolean($json, self::INCLUDE_ASSIGNED_TASKS)) { |
||
362 | $query->includeAssignedTasksInternal(); |
||
363 | } |
||
364 | if (property_exists($json, self::PROCESS_INSTANCE_ID)) { |
||
365 | $query->processInstanceId(JsonUtil::getString($json, self::PROCESS_INSTANCE_ID)); |
||
366 | } |
||
367 | if (property_exists($json, self::PROCESS_INSTANCE_ID_IN)) { |
||
368 | $query->processInstanceIdIn(JsonUtil::getArray($json, self::PROCESS_INSTANCE_ID_IN)); |
||
369 | } |
||
370 | if (property_exists($json, self::EXECUTION_ID)) { |
||
371 | $query->executionId(JsonUtil::getString($json, self::EXECUTION_ID)); |
||
372 | } |
||
373 | if (property_exists($json, self::ACTIVITY_INSTANCE_ID_IN)) { |
||
374 | $query->activityInstanceIdIn(JsonUtil::getArray($json, self::ACTIVITY_INSTANCE_ID_IN)); |
||
375 | } |
||
376 | if (property_exists($json, self::CREATED)) { |
||
377 | $query->taskCreatedOn((new \DateTime())->setTimestamp(JsonUtil::getLong($json, self::CREATED))->format('c')); |
||
378 | } |
||
379 | if (property_exists($json, self::CREATED_BEFORE)) { |
||
380 | $query->taskCreatedBefore((new \DateTime())->setTimestamp(JsonUtil::getLong($json, self::CREATED_BEFORE))->format('c')); |
||
381 | } |
||
382 | if (property_exists($json, self::CREATED_AFTER)) { |
||
383 | $query->taskCreatedAfter((new \DateTime())->setTimestamp(JsonUtil::getLong($json, self::CREATED_AFTER))->format('c')); |
||
384 | } |
||
385 | if (property_exists($json, self::UPDATED_AFTER)) { |
||
386 | $query->taskUpdatedAfter((new \DateTime())->setTimestamp(JsonUtil::getLong($json, self::UPDATED_AFTER))->format('c')); |
||
387 | } |
||
388 | if (property_exists($json, self::KEY)) { |
||
389 | $query->taskDefinitionKey(JsonUtil::getString($json, self::KEY)); |
||
390 | } |
||
391 | if (property_exists($json, self::KEYS)) { |
||
392 | $query->taskDefinitionKeyIn(JsonUtil::getArray($json, self::KEYS)); |
||
393 | } |
||
394 | if (property_exists($json, self::KEY_LIKE)) { |
||
395 | $query->taskDefinitionKeyLike(JsonUtil::getString($json, self::KEY_LIKE)); |
||
396 | } |
||
397 | if (property_exists($json, self::PARENT_TASK_ID)) { |
||
398 | $query->taskParentTaskId(JsonUtil::getString($json, self::PARENT_TASK_ID)); |
||
399 | } |
||
400 | if (property_exists($json, self::PROCESS_DEFINITION_KEY)) { |
||
401 | $query->processDefinitionKey(JsonUtil::getString($json, self::PROCESS_DEFINITION_KEY)); |
||
402 | } |
||
403 | if (property_exists($json, self::PROCESS_DEFINITION_KEYS)) { |
||
404 | $query->processDefinitionKeyIn(JsonUtil::getArray($json, self::PROCESS_DEFINITION_KEYS)); |
||
405 | } |
||
406 | if (property_exists($json, self::PROCESS_DEFINITION_ID)) { |
||
407 | $query->processDefinitionId(JsonUtil::getString($json, self::PROCESS_DEFINITION_ID)); |
||
408 | } |
||
409 | if (property_exists($json, self::PROCESS_DEFINITION_NAME)) { |
||
410 | $query->processDefinitionName(JsonUtil::getString($json, self::PROCESS_DEFINITION_NAME)); |
||
411 | } |
||
412 | if (property_exists($json, self::PROCESS_DEFINITION_NAME_LIKE)) { |
||
413 | $query->processDefinitionNameLike(JsonUtil::getString($json, self::PROCESS_DEFINITION_NAME_LIKE)); |
||
414 | } |
||
415 | if (property_exists($json, self::PROCESS_INSTANCE_BUSINESS_KEY)) { |
||
416 | $query->processInstanceBusinessKey(JsonUtil::getString($json, self::PROCESS_INSTANCE_BUSINESS_KEY)); |
||
417 | } |
||
418 | if (property_exists($json, self::PROCESS_INSTANCE_BUSINESS_KEYS)) { |
||
419 | $query->processInstanceBusinessKeyIn(JsonUtil::getArray($json, self::PROCESS_INSTANCE_BUSINESS_KEYS)); |
||
420 | } |
||
421 | if (property_exists($json, self::PROCESS_INSTANCE_BUSINESS_KEY_LIKE)) { |
||
422 | $query->processInstanceBusinessKeyLike(JsonUtil::getString($json, self::PROCESS_INSTANCE_BUSINESS_KEY_LIKE)); |
||
423 | } |
||
424 | if (property_exists($json, self::TASK_VARIABLES)) { |
||
425 | $this->addVariables($query, JsonUtil::getArray($json, self::TASK_VARIABLES), true, false); |
||
426 | } |
||
427 | if (property_exists($json, self::PROCESS_VARIABLES)) { |
||
428 | $this->addVariables($query, JsonUtil::getArray($json, self::PROCESS_VARIABLES), false, true); |
||
429 | } |
||
430 | /*if (property_exists($json, self::CASE_INSTANCE_VARIABLES)) { |
||
431 | addVariables(query, JsonUtil::getArray($json, self::CASE_INSTANCE_VARIABLES), false, false); |
||
432 | }*/ |
||
433 | if (property_exists($json, self::DUE)) { |
||
434 | $query->dueDate((new \DateTime())->setTimestamp(JsonUtil::getLong($json, self::DUE))->format('c')); |
||
435 | } |
||
436 | if (property_exists($json, self::DUE_BEFORE)) { |
||
437 | $query->dueBefore((new \DateTime())->setTimestamp(JsonUtil::getLong($json, self::DUE_BEFORE))->format('c')); |
||
438 | } |
||
439 | if (property_exists($json, self::DUE_AFTER)) { |
||
440 | $query->dueAfter((new \DateTime())->setTimestamp(JsonUtil::getLong($json, self::DUE_AFTER))->format('c')); |
||
441 | } |
||
442 | if (property_exists($json, self::WITHOUT_DUE_DATE)) { |
||
443 | $query->withoutDueDate(); |
||
444 | } |
||
445 | if (property_exists($json, self::FOLLOW_UP)) { |
||
446 | $query->followUpDate((new \DateTime())->setTimestamp(JsonUtil::getLong($json, self::FOLLOW_UP))->format('c')); |
||
447 | } |
||
448 | if (property_exists($json, self::FOLLOW_UP_BEFORE)) { |
||
449 | $query->followUpBefore((new \DateTime())->setTimestamp(JsonUtil::getLong($json, self::FOLLOW_UP_BEFORE))->format('c')); |
||
450 | } |
||
451 | if (property_exists($json, self::FOLLOW_UP_AFTER)) { |
||
452 | $query->followUpAfter((new \DateTime())->setTimestamp(JsonUtil::getLong($json, self::FOLLOW_UP_AFTER))->format('c')); |
||
453 | } |
||
454 | if (property_exists($json, self::FOLLOW_UP_NULL_ACCEPTED)) { |
||
455 | $query->setFollowUpNullAccepted(JsonUtil::getBoolean($json, self::FOLLOW_UP_NULL_ACCEPTED)); |
||
456 | } |
||
457 | if (property_exists($json, self::EXCLUDE_SUBTASKS) && JsonUtil::getBoolean($json, self::EXCLUDE_SUBTASKS)) { |
||
458 | $query->excludeSubtasks(); |
||
459 | } |
||
460 | if (property_exists($json, self::SUSPENDED) && JsonUtil::getBoolean($json, self::SUSPENDED)) { |
||
461 | $query->suspended(); |
||
462 | } |
||
463 | if (property_exists($json, self::ACTIVE) && JsonUtil::getBoolean($json, self::ACTIVE)) { |
||
464 | $query->active(); |
||
465 | } |
||
466 | /*if (property_exists($json, self::CASE_DEFINITION_KEY)) { |
||
467 | $query->caseDefinitionKey(JsonUtil::getString($json, self::CASE_DEFINITION_KEY)); |
||
468 | } |
||
469 | if (property_exists($json, self::CASE_DEFINITION_ID)) { |
||
470 | $query->caseDefinitionId(JsonUtil::getString($json, self::CASE_DEFINITION_ID)); |
||
471 | } |
||
472 | if (property_exists($json, self::CASE_DEFINITION_NAME)) { |
||
473 | $query->caseDefinitionName(JsonUtil::getString($json, self::CASE_DEFINITION_NAME)); |
||
474 | } |
||
475 | if (property_exists($json, self::CASE_DEFINITION_NAME_LIKE)) { |
||
476 | $query->caseDefinitionNameLike(JsonUtil::getString($json, self::CASE_DEFINITION_NAME_LIKE)); |
||
477 | } |
||
478 | if (property_exists($json, self::CASE_INSTANCE_ID)) { |
||
479 | $query->caseInstanceId(JsonUtil::getString($json, self::CASE_INSTANCE_ID)); |
||
480 | } |
||
481 | if (property_exists($json, self::CASE_INSTANCE_BUSINESS_KEY)) { |
||
482 | $query->caseInstanceBusinessKey(JsonUtil::getString($json, self::CASE_INSTANCE_BUSINESS_KEY)); |
||
483 | } |
||
484 | if (property_exists($json, self::CASE_INSTANCE_BUSINESS_KEY_LIKE)) { |
||
485 | $query->caseInstanceBusinessKeyLike(JsonUtil::getString($json, self::CASE_INSTANCE_BUSINESS_KEY_LIKE)); |
||
486 | } |
||
487 | if (property_exists($json, self::CASE_EXECUTION_ID)) { |
||
488 | $query->caseExecutionId(JsonUtil::getString($json, self::CASE_EXECUTION_ID)); |
||
489 | }*/ |
||
490 | if (property_exists($json, self::TENANT_IDS)) { |
||
491 | $query->tenantIdIn(JsonUtil::getArray($json, self::TENANT_IDS)); |
||
492 | } |
||
493 | if (property_exists($json, self::WITHOUT_TENANT_ID)) { |
||
494 | $query->withoutTenantId(); |
||
495 | } |
||
496 | if (property_exists($json, self::ORDERING_PROPERTIES)) { |
||
497 | $jsonArray = JsonUtil::getArray($json, self::ORDERING_PROPERTIES); |
||
498 | $query->setOrderingProperties(JsonQueryOrderingPropertyConverter::arrayConverter()->toObject($jsonArray)); |
||
499 | } |
||
500 | |||
501 | // expressions |
||
502 | foreach ($json as $key => $value) { |
||
503 | if (str_ends_with($key, "Expression")) { |
||
504 | $expression = JsonUtil::getString($json, self::key); |
||
505 | $query->addExpression(substr($key, 0, strlen($key) - strlen("Expression")), $expression); |
||
506 | } |
||
507 | } |
||
508 | |||
509 | return $query; |
||
510 | } |
||
523 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.