| Total Complexity | 45 |
| Total Lines | 285 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
Complex classes like ExecutionQueryImpl often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use ExecutionQueryImpl, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 14 | class ExecutionQueryImpl extends AbstractVariableQueryImpl implements ExecutionQueryInterface |
||
| 15 | { |
||
| 16 | protected $processDefinitionId; |
||
| 17 | protected $processDefinitionKey; |
||
| 18 | protected $businessKey; |
||
| 19 | protected $activityId; |
||
| 20 | protected $executionId; |
||
| 21 | protected $processInstanceId; |
||
| 22 | protected $eventSubscriptions; |
||
| 23 | protected $suspensionState; |
||
| 24 | protected $incidentType; |
||
| 25 | protected $incidentId; |
||
| 26 | protected $incidentMessage; |
||
| 27 | protected $incidentMessageLike; |
||
| 28 | |||
| 29 | protected $isTenantIdSet = false; |
||
| 30 | protected $tenantIds = []; |
||
| 31 | |||
| 32 | public function __construct(CommandExecutorInterface $commandExecutor) |
||
| 33 | { |
||
| 34 | parent::__construct($commandExecutor); |
||
| 35 | } |
||
| 36 | |||
| 37 | public function processDefinitionId(string $processDefinitionId): ExecutionQueryImpl |
||
| 38 | { |
||
| 39 | EnsureUtil::ensureNotNull("Process definition id", "processDefinitionId", $processDefinitionId); |
||
| 40 | $this->processDefinitionId = $processDefinitionId; |
||
| 41 | return $this; |
||
| 42 | } |
||
| 43 | |||
| 44 | public function processDefinitionKey(string $processDefinitionKey): ExecutionQueryImpl |
||
| 45 | { |
||
| 46 | EnsureUtil::ensureNotNull("Process definition key", "processDefinitionKey", $processDefinitionKey); |
||
| 47 | $this->processDefinitionKey = $processDefinitionKey; |
||
| 48 | return $this; |
||
| 49 | } |
||
| 50 | |||
| 51 | public function processInstanceId(string $processInstanceId): ExecutionQueryImpl |
||
| 52 | { |
||
| 53 | EnsureUtil::ensureNotNull("Process instance id", "processInstanceId", $processInstanceId); |
||
| 54 | $this->processInstanceId = $processInstanceId; |
||
| 55 | return $this; |
||
| 56 | } |
||
| 57 | |||
| 58 | public function processInstanceBusinessKey(string $businessKey): ExecutionQueryInterface |
||
| 63 | } |
||
| 64 | |||
| 65 | public function executionId(string $executionId): ExecutionQueryImpl |
||
| 66 | { |
||
| 67 | EnsureUtil::ensureNotNull("Execution id", "executionId", $executionId); |
||
| 68 | $this->executionId = $executionId; |
||
| 69 | return $this; |
||
| 70 | } |
||
| 71 | |||
| 72 | public function activityId(string $activityId): ExecutionQueryImpl |
||
| 73 | { |
||
| 74 | $this->activityId = $activityId; |
||
| 75 | return $this; |
||
| 76 | } |
||
| 77 | |||
| 78 | public function signalEventSubscription(string $signalName): ExecutionQueryInterface |
||
| 79 | { |
||
| 80 | return $this->eventSubscription(EventType::signal(), $signalName); |
||
| 81 | } |
||
| 82 | |||
| 83 | public function signalEventSubscriptionName(string $signalName): ExecutionQueryInterface |
||
| 84 | { |
||
| 85 | return $this->eventSubscription(EventType::signal(), $signalName); |
||
| 86 | } |
||
| 87 | |||
| 88 | public function messageEventSubscriptionName(string $messageName): ExecutionQueryInterface |
||
| 89 | { |
||
| 90 | return $this->eventSubscription(EventType::message(), $messageName); |
||
| 91 | } |
||
| 92 | |||
| 93 | public function messageEventSubscription(): ExecutionQueryInterface |
||
| 94 | { |
||
| 95 | return $this->eventSubscription(EventType::message(), null); |
||
| 96 | } |
||
| 97 | |||
| 98 | public function eventSubscription(EventType $eventType, string $eventName): ExecutionQueryInterface |
||
| 99 | { |
||
| 100 | EnsureUtil::ensureNotNull("event type", "eventType", $eventType); |
||
| 101 | if (EventType::message() != $eventType) { |
||
| 102 | // event name is optional for message events |
||
| 103 | EnsureUtil::ensureNotNull("event name", "eventName", $eventName); |
||
| 104 | } |
||
| 105 | if (empty($this->eventSubscriptions)) { |
||
| 106 | $this->eventSubscriptions = []; |
||
| 107 | } |
||
| 108 | $this->eventSubscriptions[] = new EventSubscriptionQueryValue($eventName, $eventType->name()); |
||
| 109 | return $this; |
||
| 110 | } |
||
| 111 | |||
| 112 | public function suspended(): ExecutionQueryInterface |
||
| 113 | { |
||
| 114 | $this->suspensionState = SuspensionState::suspended(); |
||
| 115 | return $this; |
||
| 116 | } |
||
| 117 | |||
| 118 | public function active(): ExecutionQueryInterface |
||
| 119 | { |
||
| 120 | $this->suspensionState = SuspensionState::active(); |
||
| 121 | return $this; |
||
| 122 | } |
||
| 123 | |||
| 124 | public function processVariableValueEquals(string $variableName, $variableValue): ExecutionQueryInterface |
||
| 125 | { |
||
| 126 | $this->addVariable($variableName, $variableValue, QueryOperator::EQUALS, false); |
||
| 127 | return $this; |
||
| 128 | } |
||
| 129 | |||
| 130 | public function processVariableValueNotEquals(string $variableName, $variableValue): ExecutionQueryInterface |
||
| 131 | { |
||
| 132 | $this->addVariable($variableName, $variableValue, QueryOperator::NOT_EQUALS, false); |
||
| 133 | return $this; |
||
| 134 | } |
||
| 135 | |||
| 136 | public function incidentType(string $incidentType): ExecutionQueryInterface |
||
| 137 | { |
||
| 138 | EnsureUtil::ensureNotNull("incident type", "incidentType", $incidentType); |
||
| 139 | $this->incidentType = $incidentType; |
||
| 140 | return $this; |
||
| 141 | } |
||
| 142 | |||
| 143 | public function incidentId(string $incidentId): ExecutionQueryInterface |
||
| 144 | { |
||
| 145 | EnsureUtil::ensureNotNull("incident id", "incidentId", $incidentId); |
||
| 146 | $this->incidentId = $incidentId; |
||
| 147 | return $this; |
||
| 148 | } |
||
| 149 | |||
| 150 | public function incidentMessage(string $incidentMessage): ExecutionQueryInterface |
||
| 151 | { |
||
| 152 | EnsureUtil::ensureNotNull("incident message", "incidentMessage", $incidentMessage); |
||
| 153 | $this->incidentMessage = $incidentMessage; |
||
| 154 | return $this; |
||
| 155 | } |
||
| 156 | |||
| 157 | public function incidentMessageLike(string $incidentMessageLike): ExecutionQueryInterface |
||
| 158 | { |
||
| 159 | EnsureUtil::ensureNotNull("incident messageLike", "incidentMessageLike", $incidentMessageLike); |
||
| 160 | $this->incidentMessageLike = $incidentMessageLike; |
||
| 161 | return $this; |
||
| 162 | } |
||
| 163 | |||
| 164 | public function tenantIdIn(array $tenantIds): ExecutionQueryInterface |
||
| 165 | { |
||
| 166 | EnsureUtil::ensureNotNull("tenantIds", "tenantIds", $tenantIds); |
||
| 167 | $this->tenantIds = $tenantIds; |
||
| 168 | $this->isTenantIdSet = true; |
||
| 169 | return $this; |
||
| 170 | } |
||
| 171 | |||
| 172 | public function withoutTenantId(): ExecutionQueryInterface |
||
| 173 | { |
||
| 174 | $this->tenantIds = null; |
||
| 175 | $this->isTenantIdSet = true; |
||
| 176 | return $this; |
||
| 177 | } |
||
| 178 | |||
| 179 | //ordering //////////////////////////////////////////////////// |
||
| 180 | |||
| 181 | public function orderByProcessInstanceId(): ExecutionQueryImpl |
||
| 182 | { |
||
| 183 | $this->orderBy(ExecutionQueryProperty::processInstanceId()); |
||
| 184 | return $this; |
||
| 185 | } |
||
| 186 | |||
| 187 | public function orderByProcessDefinitionId(): ExecutionQueryImpl |
||
| 188 | { |
||
| 189 | $this->orderBy(new QueryOrderingProperty(QueryOrderingProperty::RELATION_PROCESS_DEFINITION, ExecutionQueryProperty::processDefinitionId())); |
||
| 190 | return $this; |
||
| 191 | } |
||
| 192 | |||
| 193 | public function orderByProcessDefinitionKey(): ExecutionQueryImpl |
||
| 194 | { |
||
| 195 | $this->orderBy(new QueryOrderingProperty(QueryOrderingProperty::RELATION_PROCESS_DEFINITION, ExecutionQueryProperty::processDefinitionKey())); |
||
| 196 | return $this; |
||
| 197 | } |
||
| 198 | |||
| 199 | public function orderByTenantId(): ExecutionQueryInterface |
||
| 200 | { |
||
| 201 | $this->orderBy(ExecutionQueryProperty::tenantId()); |
||
| 202 | return $this; |
||
| 203 | } |
||
| 204 | |||
| 205 | //results //////////////////////////////////////////////////// |
||
| 206 | public function executeCount(CommandContext $commandContext): int |
||
| 207 | { |
||
| 208 | $this->checkQueryOk(); |
||
| 209 | $this->ensureVariablesInitialized(); |
||
| 210 | return $commandContext |
||
| 211 | ->getExecutionManager() |
||
| 212 | ->findExecutionCountByQueryCriteria($this); |
||
| 213 | } |
||
| 214 | |||
| 215 | public function executeList(CommandContext $commandContext, Page $page): array |
||
| 216 | { |
||
| 217 | $this->checkQueryOk(); |
||
| 218 | $this->ensureVariablesInitialized(); |
||
| 219 | return $commandContext |
||
| 220 | ->getExecutionManager() |
||
| 221 | ->findExecutionsByQueryCriteria($this, $page); |
||
| 222 | } |
||
| 223 | |||
| 224 | //getters //////////////////////////////////////////////////// |
||
| 225 | |||
| 226 | public function getProcessDefinitionKey(): string |
||
| 227 | { |
||
| 228 | return $this->processDefinitionKey; |
||
| 229 | } |
||
| 230 | |||
| 231 | public function getProcessDefinitionId(): string |
||
| 232 | { |
||
| 233 | return $this->processDefinitionId; |
||
| 234 | } |
||
| 235 | |||
| 236 | public function getActivityId(): string |
||
| 237 | { |
||
| 238 | return $this->activityId; |
||
| 239 | } |
||
| 240 | |||
| 241 | public function getProcessInstanceId(): string |
||
| 242 | { |
||
| 243 | return $this->processInstanceId; |
||
| 244 | } |
||
| 245 | |||
| 246 | public function getProcessInstanceIds(): array |
||
| 247 | { |
||
| 248 | return []; |
||
| 249 | } |
||
| 250 | |||
| 251 | public function getBusinessKey(): string |
||
| 252 | { |
||
| 253 | return $this->businessKey; |
||
| 254 | } |
||
| 255 | |||
| 256 | public function getExecutionId(): string |
||
| 257 | { |
||
| 258 | return $this->executionId; |
||
| 259 | } |
||
| 260 | |||
| 261 | public function getSuspensionState(): SuspensionState |
||
| 262 | { |
||
| 263 | return $this->suspensionState; |
||
| 264 | } |
||
| 265 | |||
| 266 | public function setSuspensionState(SuspensionState $suspensionState): void |
||
| 267 | { |
||
| 268 | $this->suspensionState = $suspensionState; |
||
| 269 | } |
||
| 270 | |||
| 271 | public function getEventSubscriptions(): array |
||
| 274 | } |
||
| 275 | |||
| 276 | public function setEventSubscriptions(array $eventSubscriptions): void |
||
| 277 | { |
||
| 278 | $this->eventSubscriptions = $eventSubscriptions; |
||
| 279 | } |
||
| 280 | |||
| 281 | public function getIncidentId(): string |
||
| 282 | { |
||
| 283 | return $this->incidentId; |
||
| 284 | } |
||
| 285 | |||
| 286 | public function getIncidentType(): string |
||
| 289 | } |
||
| 290 | |||
| 291 | public function getIncidentMessage(): string |
||
| 292 | { |
||
| 293 | return $this->incidentMessage; |
||
| 294 | } |
||
| 295 | |||
| 296 | public function getIncidentMessageLike(): string |
||
| 297 | { |
||
| 298 | return $this->incidentMessageLike; |
||
| 299 | } |
||
| 300 | } |
||
| 301 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths