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