| Conditions | 32 | 
| Paths | 49 | 
| Total Lines | 187 | 
| Code Lines | 132 | 
| 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  | 
            ||
| 33 | public function inContextOf(/*JobEntity|JobDefinitionEntity*/$data, $arg2 = null, $arg3 = null): UserOperationLogContextEntryBuilder  | 
            ||
| 34 |     { | 
            ||
| 35 |         if ($data instanceof JobEntity) { | 
            ||
| 36 | $job = $data;  | 
            ||
| 37 | $this->entry->setJobDefinitionId($job->getJobDefinitionId());  | 
            ||
| 38 | $this->entry->setProcessInstanceId($job->getProcessInstanceId());  | 
            ||
| 39 | $this->entry->setProcessDefinitionId($job->getProcessDefinitionId());  | 
            ||
| 40 | $this->entry->setProcessDefinitionKey($job->getProcessDefinitionKey());  | 
            ||
| 41 | $this->entry->setDeploymentId($job->getDeploymentId());  | 
            ||
| 42 | |||
| 43 | $execution = $job->getExecution();  | 
            ||
| 44 |             if ($execution !== null) { | 
            ||
| 45 | $this->entry->setRootProcessInstanceId($execution->getRootProcessInstanceId());  | 
            ||
| 46 | }  | 
            ||
| 47 | |||
| 48 | return $this;  | 
            ||
| 49 |         } elseif ($data instanceof JobDefinitionEntity) { | 
            ||
| 50 | $jobDefinition = $data;  | 
            ||
| 51 | $this->entry->setJobDefinitionId($jobDefinition->getId());  | 
            ||
| 52 | $this->entry->setProcessDefinitionId($jobDefinition->getProcessDefinitionId());  | 
            ||
| 53 | $this->entry->setProcessDefinitionKey($jobDefinition->getProcessDefinitionKey());  | 
            ||
| 54 | |||
| 55 |             if ($jobDefinition->getProcessDefinitionId() !== null) { | 
            ||
| 
                                                                                                    
                        
                         | 
                |||
| 56 | $processDefinition = Context::getProcessEngineConfiguration()  | 
            ||
| 57 | ->getDeploymentCache()  | 
            ||
| 58 | ->findDeployedProcessDefinitionById($jobDefinition->getProcessDefinitionId());  | 
            ||
| 59 | $this->entry->setDeploymentId($processDefinition->getDeploymentId());  | 
            ||
| 60 | }  | 
            ||
| 61 | return $this;  | 
            ||
| 62 |         } elseif ($data instanceof ExecutionEntity) { | 
            ||
| 63 |             if (is_array($arg2)) { | 
            ||
| 64 | $processInstance = $data;  | 
            ||
| 65 | $propertyChanges = $arg2;  | 
            ||
| 66 |                 if (empty($propertyChanges)) { | 
            ||
| 67 |                     if (UserOperationLogEntryInterface::OPERATION_TYPE_CREATE == $this->entry->getOperationType()) { | 
            ||
| 68 | $propertyChanges = PropertyChange::emptyChange();  | 
            ||
| 69 | }  | 
            ||
| 70 | }  | 
            ||
| 71 | $this->entry->setPropertyChanges($propertyChanges);  | 
            ||
| 72 | $this->entry->setRootProcessInstanceId($processInstance->getRootProcessInstanceId());  | 
            ||
| 73 | $this->entry->setProcessInstanceId($processInstance->getProcessInstanceId());  | 
            ||
| 74 | $this->entry->setProcessDefinitionId($processInstance->getProcessDefinitionId());  | 
            ||
| 75 | $this->entry->setExecutionId($processInstance->getId());  | 
            ||
| 76 | //$this->entry->setCaseInstanceId($processInstance->getCaseInstanceId());  | 
            ||
| 77 | |||
| 78 | $definition = $processInstance->getProcessDefinition();  | 
            ||
| 79 |                 if ($definition !== null) { | 
            ||
| 80 | $this->entry->setProcessDefinitionKey($definition->getKey());  | 
            ||
| 81 | $this->entry->setDeploymentId($definition->getDeploymentId());  | 
            ||
| 82 | }  | 
            ||
| 83 | |||
| 84 | return $this;  | 
            ||
| 85 |             } else { | 
            ||
| 86 | $execution = $data;  | 
            ||
| 87 | $this->entry->setProcessInstanceId($execution->getProcessInstanceId());  | 
            ||
| 88 | $this->entry->setRootProcessInstanceId($execution->getRootProcessInstanceId());  | 
            ||
| 89 | $this->entry->setProcessDefinitionId($execution->getProcessDefinitionId());  | 
            ||
| 90 | |||
| 91 | $processDefinition = $execution->getProcessDefinition();  | 
            ||
| 92 | $this->entry->setProcessDefinitionKey($processDefinition->getKey());  | 
            ||
| 93 | $this->entry->setDeploymentId($processDefinition->getDeploymentId());  | 
            ||
| 94 | |||
| 95 | return $this;  | 
            ||
| 96 | }  | 
            ||
| 97 |         } elseif ($data instanceof ProcessDefinitionEntity) { | 
            ||
| 98 | $processDefinition = $data;  | 
            ||
| 99 | $this->entry->setProcessDefinitionId($processDefinition->getId());  | 
            ||
| 100 | $this->entry->setProcessDefinitionKey($processDefinition->getKey());  | 
            ||
| 101 | $this->entry->setDeploymentId($processDefinition->getDeploymentId());  | 
            ||
| 102 | return $this;  | 
            ||
| 103 |         } elseif ($data instanceof TaskEntity) { | 
            ||
| 104 | $task = $data;  | 
            ||
| 105 | $propertyChanges = $arg2;  | 
            ||
| 106 | |||
| 107 |             if (empty($propertyChanges)) { | 
            ||
| 108 |                 if (UserOperationLogEntryInterface::OPERATION_TYPE_CREATE == $this->entry->getOperationType()) { | 
            ||
| 109 | $propertyChanges = PropertyChange::emptyChange();  | 
            ||
| 110 | }  | 
            ||
| 111 | }  | 
            ||
| 112 | $this->entry->setPropertyChanges($propertyChanges);  | 
            ||
| 113 | |||
| 114 | $definition = $task->getProcessDefinition();  | 
            ||
| 115 |             if ($definition !== null) { | 
            ||
| 116 | $this->entry->setProcessDefinitionKey($definition->getKey());  | 
            ||
| 117 | $this->entry->setDeploymentId($definition->getDeploymentId());  | 
            ||
| 118 |             }/* elseif (task.getCaseDefinitionId() !== null) { | 
            ||
| 119 | $this->entry->setDeploymentId(task.getCaseDefinition().getDeploymentId());  | 
            ||
| 120 | }*/  | 
            ||
| 121 | |||
| 122 | $this->entry->setProcessDefinitionId($task->getProcessDefinitionId());  | 
            ||
| 123 | $this->entry->setProcessInstanceId($task->getProcessInstanceId());  | 
            ||
| 124 | $this->entry->setExecutionId($task->getExecutionId());  | 
            ||
| 125 | /*$this->entry->setCaseDefinitionId(task.getCaseDefinitionId());  | 
            ||
| 126 | $this->entry->setCaseInstanceId(task.getCaseInstanceId());  | 
            ||
| 127 | $this->entry->setCaseExecutionId(task.getCaseExecutionId());*/  | 
            ||
| 128 | $this->entry->setTaskId($task->getId());  | 
            ||
| 129 | |||
| 130 | $execution = $task->getExecution();  | 
            ||
| 131 |             if ($execution !== null) { | 
            ||
| 132 | $this->entry->setRootProcessInstanceId($execution->getRootProcessInstanceId());  | 
            ||
| 133 | }  | 
            ||
| 134 | |||
| 135 | return $this;  | 
            ||
| 136 |         } elseif ($data instanceof HistoricTaskInstanceInterface) { | 
            ||
| 137 | $task = $data;  | 
            ||
| 138 | $propertyChanges = $arg2;  | 
            ||
| 139 |             if (empty($propertyChanges)) { | 
            ||
| 140 |                 if (UserOperationLogEntryInterface::OPERATION_TYPE_CREATE == $this->entry->getOperationType()) { | 
            ||
| 141 | $propertyChanges = PropertyChange::emptyChange();  | 
            ||
| 142 | }  | 
            ||
| 143 | }  | 
            ||
| 144 | $this->entry->setPropertyChanges($propertyChanges);  | 
            ||
| 145 | $this->entry->setProcessDefinitionKey($task->getProcessDefinitionKey());  | 
            ||
| 146 | $this->entry->setProcessDefinitionId($task->getProcessDefinitionId());  | 
            ||
| 147 | $this->entry->setProcessInstanceId($task->getProcessInstanceId());  | 
            ||
| 148 | $this->entry->setExecutionId($task->getExecutionId());  | 
            ||
| 149 | /*$this->entry->setCaseDefinitionId(task.getCaseDefinitionId());  | 
            ||
| 150 | $this->entry->setCaseInstanceId(task.getCaseInstanceId());  | 
            ||
| 151 | $this->entry->setCaseExecutionId(task.getCaseExecutionId());*/  | 
            ||
| 152 | $this->entry->setTaskId($task->getId());  | 
            ||
| 153 | $this->entry->setRootProcessInstanceId($task->getRootProcessInstanceId());  | 
            ||
| 154 | |||
| 155 | return $this;  | 
            ||
| 156 |         } elseif ($data instanceof HistoryEvent) { | 
            ||
| 157 | $historyEvent = $data;  | 
            ||
| 158 | $definition = $arg2;  | 
            ||
| 159 | $propertyChanges = $arg3;  | 
            ||
| 160 |             if (empty($propertyChanges)) { | 
            ||
| 161 |                 if (UserOperationLogEntryInterface::OPERATION_TYPE_CREATE == $this->entry->getOperationType()) { | 
            ||
| 162 | $propertyChanges = PropertyChange::emptyChange();  | 
            ||
| 163 | }  | 
            ||
| 164 | }  | 
            ||
| 165 | $this->entry->setPropertyChanges($propertyChanges);  | 
            ||
| 166 | $this->entry->setRootProcessInstanceId($historyEvent->getRootProcessInstanceId());  | 
            ||
| 167 | $this->entry->setProcessDefinitionId($historyEvent->getProcessDefinitionId());  | 
            ||
| 168 | $this->entry->setProcessInstanceId($historyEvent->getProcessInstanceId());  | 
            ||
| 169 | $this->entry->setExecutionId($historyEvent->getExecutionId());  | 
            ||
| 170 | /*$this->entry->setCaseDefinitionId(historyEvent.getCaseDefinitionId());  | 
            ||
| 171 | $this->entry->setCaseInstanceId(historyEvent.getCaseInstanceId());  | 
            ||
| 172 | $this->entry->setCaseExecutionId(historyEvent.getCaseExecutionId());*/  | 
            ||
| 173 | |||
| 174 |             if ($definition !== null) { | 
            ||
| 175 |                 if ($definition instanceof ProcessDefinitionEntity) { | 
            ||
| 176 | $this->entry->setProcessDefinitionKey($definition->getKey());  | 
            ||
| 177 | }  | 
            ||
| 178 | $this->entry->setDeploymentId($definition->getDeploymentId());  | 
            ||
| 179 | }  | 
            ||
| 180 | |||
| 181 | return $this;  | 
            ||
| 182 |         } elseif ($data instanceof HistoricVariableInstanceEntity) { | 
            ||
| 183 | $variable = $data;  | 
            ||
| 184 | $definition = $arg2;  | 
            ||
| 185 | $propertyChanges = $arg3;  | 
            ||
| 186 |             if (empty($propertyChanges)) { | 
            ||
| 187 |                 if (UserOperationLogEntryInterface::OPERATION_TYPE_CREATE == $this->entry->getOperationType()) { | 
            ||
| 188 | $propertyChanges = PropertyChange::emptyChange();  | 
            ||
| 189 | }  | 
            ||
| 190 | }  | 
            ||
| 191 | $this->entry->setPropertyChanges($propertyChanges);  | 
            ||
| 192 | $this->entry->setRootProcessInstanceId($variable->getRootProcessInstanceId());  | 
            ||
| 193 | $this->entry->setProcessDefinitionId($variable->getProcessDefinitionId());  | 
            ||
| 194 | $this->entry->setProcessInstanceId($variable->getProcessInstanceId());  | 
            ||
| 195 | $this->entry->setExecutionId($variable->getExecutionId());  | 
            ||
| 196 | /*$this->entry->setCaseDefinitionId(variable.getCaseDefinitionId());  | 
            ||
| 197 | $this->entry->setCaseInstanceId(variable.getCaseInstanceId());  | 
            ||
| 198 | $this->entry->setCaseExecutionId(variable.getCaseExecutionId());*/  | 
            ||
| 199 | $this->entry->setTaskId($variable->getTaskId());  | 
            ||
| 200 | |||
| 201 |             if ($definition !== null) { | 
            ||
| 202 |                 if ($definition instanceof ProcessDefinitionEntity) { | 
            ||
| 203 | $this->entry->setProcessDefinitionKey($definition->getKey());  | 
            ||
| 204 | }  | 
            ||
| 205 | $this->entry->setDeploymentId($definition->getDeploymentId());  | 
            ||
| 206 | }  | 
            ||
| 207 | |||
| 208 | return $this;  | 
            ||
| 209 |         } elseif ($data instanceof ExternalTaskEntity) { | 
            ||
| 210 | $task = $data;  | 
            ||
| 211 | $execution = $arg2;  | 
            ||
| 212 | $definition = $arg3;  | 
            ||
| 213 |             if ($execution !== null) { | 
            ||
| 214 | $this->inContextOf($execution);  | 
            ||
| 215 |             } elseif ($definition !== null) { | 
            ||
| 216 | $this->inContextOf($definition);  | 
            ||
| 217 | }  | 
            ||
| 218 | $this->entry->setExternalTaskId($task->getId());  | 
            ||
| 219 | return $this;  | 
            ||
| 220 | }  | 
            ||
| 310 |