| Total Complexity | 49 |
| Total Lines | 307 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
Complex classes like ExternalTaskQueryImpl 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 ExternalTaskQueryImpl, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 18 | class ExternalTaskQueryImpl extends AbstractQuery implements ExternalTaskQueryInterface |
||
| 19 | { |
||
| 20 | protected $externalTaskId; |
||
| 21 | protected $externalTaskIds = []; |
||
| 22 | protected $workerId; |
||
| 23 | protected $lockExpirationBefore; |
||
| 24 | protected $lockExpirationAfter; |
||
| 25 | protected $topicName; |
||
| 26 | protected $locked; |
||
| 27 | protected $notLocked; |
||
| 28 | protected $executionId; |
||
| 29 | protected $processInstanceId; |
||
| 30 | protected $processInstanceIdIn = []; |
||
| 31 | protected $processDefinitionId; |
||
| 32 | protected $activityId; |
||
| 33 | protected $activityIdIn = []; |
||
| 34 | protected $suspensionState; |
||
| 35 | protected $priorityHigherThanOrEquals; |
||
| 36 | protected $priorityLowerThanOrEquals; |
||
| 37 | protected $retriesLeft; |
||
| 38 | protected $tenantIds = []; |
||
| 39 | |||
| 40 | public function __construct(CommandExecutorInterface $commandExecutor) |
||
| 41 | { |
||
| 42 | parent::__construct($commandExecutor); |
||
| 43 | } |
||
| 44 | |||
| 45 | public function externalTaskId(string $externalTaskId): ExternalTaskQueryInterface |
||
| 46 | { |
||
| 47 | EnsureUtil::ensureNotNull("externalTaskId", "externalTaskId", $externalTaskId); |
||
| 48 | $this->externalTaskId = $externalTaskId; |
||
| 49 | return $this; |
||
| 50 | } |
||
| 51 | |||
| 52 | public function externalTaskIdIn(array $externalTaskIds): ExternalTaskQueryInterface |
||
| 53 | { |
||
| 54 | EnsureUtil::ensureNotEmpty("Set of external task ids", "externalTaskIds", $externalTaskIds); |
||
| 55 | $this->externalTaskIds = $externalTaskIds; |
||
| 56 | return $this; |
||
| 57 | } |
||
| 58 | |||
| 59 | public function workerId(string $workerId): ExternalTaskQueryInterface |
||
| 60 | { |
||
| 61 | EnsureUtil::ensureNotNull("workerId", "workerId", $workerId); |
||
| 62 | $this->workerId = $workerId; |
||
| 63 | return $this; |
||
| 64 | } |
||
| 65 | |||
| 66 | public function lockExpirationBefore(string $lockExpirationDate): ExternalTaskQueryInterface |
||
| 67 | { |
||
| 68 | EnsureUtil::ensureNotNull("lockExpirationBefore", "lockExpirationDate", $lockExpirationDate); |
||
| 69 | $this->lockExpirationBefore = $lockExpirationDate; |
||
| 70 | return $this; |
||
| 71 | } |
||
| 72 | |||
| 73 | public function lockExpirationAfter(string $lockExpirationDate): ExternalTaskQueryInterface |
||
| 74 | { |
||
| 75 | EnsureUtil::ensureNotNull("lockExpirationAfter", "lockExpirationDate", $lockExpirationDate); |
||
| 76 | $this->lockExpirationAfter = $lockExpirationDate; |
||
| 77 | return $this; |
||
| 78 | } |
||
| 79 | |||
| 80 | public function topicName(string $topicName): ExternalTaskQueryInterface |
||
| 81 | { |
||
| 82 | EnsureUtil::ensureNotNull("topicName", "topicName", $topicName); |
||
| 83 | $this->topicName = $topicName; |
||
| 84 | return $this; |
||
| 85 | } |
||
| 86 | |||
| 87 | public function locked(): ExternalTaskQueryInterface |
||
| 88 | { |
||
| 89 | $this->locked = true; |
||
| 90 | return $this; |
||
| 91 | } |
||
| 92 | |||
| 93 | public function notLocked(): ExternalTaskQueryInterface |
||
| 94 | { |
||
| 95 | $this->notLocked = true; |
||
| 96 | return $this; |
||
| 97 | } |
||
| 98 | |||
| 99 | public function executionId(string $executionId): ExternalTaskQueryInterface |
||
| 100 | { |
||
| 101 | EnsureUtil::ensureNotNull("executionId", "executionId", $executionId); |
||
| 102 | $this->executionId = $executionId; |
||
| 103 | return $this; |
||
| 104 | } |
||
| 105 | |||
| 106 | public function processInstanceId(string $processInstanceId): ExternalTaskQueryInterface |
||
| 107 | { |
||
| 108 | EnsureUtil::ensureNotNull("processInstanceId", "processInstanceId", $processInstanceId); |
||
| 109 | $this->processInstanceId = $processInstanceId; |
||
| 110 | return $this; |
||
| 111 | } |
||
| 112 | |||
| 113 | public function processInstanceIdIn(array $processInstanceIdIn): ExternalTaskQueryInterface |
||
| 114 | { |
||
| 115 | EnsureUtil::ensureNotNull("processInstanceIdIn", "processInstanceIdIn", $processInstanceIdIn); |
||
| 116 | $this->processInstanceIdIn = $processInstanceIdIn; |
||
| 117 | return $this; |
||
| 118 | } |
||
| 119 | |||
| 120 | public function processDefinitionId(string $processDefinitionId): ExternalTaskQueryInterface |
||
| 121 | { |
||
| 122 | EnsureUtil::ensureNotNull("processDefinitionId", "processDefinitionId", $processDefinitionId); |
||
| 123 | $this->processDefinitionId = $processDefinitionId; |
||
| 124 | return $this; |
||
| 125 | } |
||
| 126 | |||
| 127 | public function activityId(string $activityId): ExternalTaskQueryInterface |
||
| 128 | { |
||
| 129 | EnsureUtil::ensureNotNull("activityId", "activityId", $activityId); |
||
| 130 | $this->activityId = $activityId; |
||
| 131 | return $this; |
||
| 132 | } |
||
| 133 | |||
| 134 | public function activityIdIn(array $activityIdIn): ExternalTaskQueryInterface |
||
| 135 | { |
||
| 136 | EnsureUtil::ensureNotNull("activityIdIn", "activityIdIn", $activityIdIn); |
||
| 137 | $this->activityIdIn = $activityIdIn; |
||
| 138 | return $this; |
||
| 139 | } |
||
| 140 | |||
| 141 | public function priorityHigherThanOrEquals(int $priority): ExternalTaskQueryInterface |
||
| 142 | { |
||
| 143 | $this->priorityHigherThanOrEquals = $priority; |
||
| 144 | return $this; |
||
| 145 | } |
||
| 146 | |||
| 147 | public function priorityLowerThanOrEquals(int $priority): ExternalTaskQueryInterface |
||
| 148 | { |
||
| 149 | $this->priorityLowerThanOrEquals = $priority; |
||
| 150 | return $this; |
||
| 151 | } |
||
| 152 | |||
| 153 | public function suspended(): ExternalTaskQueryInterface |
||
| 154 | { |
||
| 155 | $this->suspensionState = SuspensionState::suspended(); |
||
| 156 | return $this; |
||
| 157 | } |
||
| 158 | |||
| 159 | public function active(): ExternalTaskQueryInterface |
||
| 160 | { |
||
| 161 | $this->suspensionState = SuspensionState::active(); |
||
| 162 | return $this; |
||
| 163 | } |
||
| 164 | |||
| 165 | public function withRetriesLeft(): ExternalTaskQueryInterface |
||
| 166 | { |
||
| 167 | $this->retriesLeft = true; |
||
| 168 | return $this; |
||
| 169 | } |
||
| 170 | |||
| 171 | public function noRetriesLeft(): ExternalTaskQueryInterface |
||
| 172 | { |
||
| 173 | $this->retriesLeft = false; |
||
| 174 | return $this; |
||
| 175 | } |
||
| 176 | |||
| 177 | protected function hasExcludingConditions(): bool |
||
| 178 | { |
||
| 179 | return parent::hasExcludingConditions() |
||
| 180 | || CompareUtil::areNotInAscendingOrder($this->priorityHigherThanOrEquals, $this->priorityLowerThanOrEquals); |
||
| 181 | } |
||
| 182 | |||
| 183 | public function tenantIdIn(array $tenantIds): ExternalTaskQueryInterface |
||
| 184 | { |
||
| 185 | EnsureUtil::ensureNotNull("tenantIds", "tenantIds", $tenantIds); |
||
| 186 | $this->tenantIds = $tenantIds; |
||
| 187 | return $this; |
||
| 188 | } |
||
| 189 | |||
| 190 | public function orderById(): ExternalTaskQueryInterface |
||
| 191 | { |
||
| 192 | return $this->orderBy(ExternalTaskQueryProperty::id()); |
||
| 193 | } |
||
| 194 | |||
| 195 | public function orderByLockExpirationTime(): ExternalTaskQueryInterface |
||
| 196 | { |
||
| 197 | return $this->orderBy(ExternalTaskQueryProperty::lockExpirationTime()); |
||
| 198 | } |
||
| 199 | |||
| 200 | public function orderByProcessInstanceId(): ExternalTaskQueryInterface |
||
| 201 | { |
||
| 202 | return $this->orderBy(ExternalTaskQueryProperty::processInstanceId()); |
||
| 203 | } |
||
| 204 | |||
| 205 | public function orderByProcessDefinitionId(): ExternalTaskQueryInterface |
||
| 206 | { |
||
| 207 | return $this->orderBy(ExternalTaskQueryProperty::processDefinitionId()); |
||
| 208 | } |
||
| 209 | |||
| 210 | public function orderByProcessDefinitionKey(): ExternalTaskQueryInterface |
||
| 211 | { |
||
| 212 | return $this->orderBy(ExternalTaskQueryProperty::processDefinitionKey()); |
||
| 213 | } |
||
| 214 | |||
| 215 | public function orderByTenantId(): ExternalTaskQueryInterface |
||
| 216 | { |
||
| 217 | return $this->orderBy(ExternalTaskQueryProperty::tenantId()); |
||
| 218 | } |
||
| 219 | |||
| 220 | public function orderByPriority(): ExternalTaskQueryInterface |
||
| 221 | { |
||
| 222 | return $this->orderBy(ExternalTaskQueryProperty::priority()); |
||
| 223 | } |
||
| 224 | |||
| 225 | public function executeCount(CommandContext $commandContext): int |
||
| 226 | { |
||
| 227 | $this->checkQueryOk(); |
||
| 228 | return $commandContext |
||
| 229 | ->getExternalTaskManager() |
||
| 230 | ->findExternalTaskCountByQueryCriteria($this); |
||
| 231 | } |
||
| 232 | |||
| 233 | public function executeList(CommandContext $commandContext, Page $page): array |
||
| 234 | { |
||
| 235 | $this->checkQueryOk(); |
||
| 236 | return $commandContext |
||
| 237 | ->getExternalTaskManager() |
||
| 238 | ->findExternalTasksByQueryCriteria($this); |
||
| 239 | } |
||
| 240 | |||
| 241 | public function executeIdsList(CommandContext $commandContext): array |
||
| 242 | { |
||
| 243 | $this->checkQueryOk(); |
||
| 244 | return $commandContext |
||
| 245 | ->getExternalTaskManager() |
||
| 246 | ->findExternalTaskIdsByQueryCriteria($this); |
||
| 247 | } |
||
| 248 | |||
| 249 | public function executeDeploymentIdMappingsList(CommandContext $commandContext): array |
||
| 250 | { |
||
| 251 | $this->checkQueryOk(); |
||
| 252 | return $commandContext |
||
| 253 | ->getExternalTaskManager() |
||
| 254 | ->findDeploymentIdMappingsByQueryCriteria($this); |
||
| 255 | } |
||
| 256 | |||
| 257 | public function getExternalTaskId(): string |
||
| 258 | { |
||
| 259 | return $this->externalTaskId; |
||
| 260 | } |
||
| 261 | |||
| 262 | public function getWorkerId(): string |
||
| 263 | { |
||
| 264 | return $this->workerId; |
||
| 265 | } |
||
| 266 | |||
| 267 | public function getLockExpirationBefore(): string |
||
| 268 | { |
||
| 269 | return $this->lockExpirationBefore; |
||
| 270 | } |
||
| 271 | |||
| 272 | public function getLockExpirationAfter(): string |
||
| 273 | { |
||
| 274 | return $this->lockExpirationAfter; |
||
| 275 | } |
||
| 276 | |||
| 277 | public function getTopicName(): string |
||
| 278 | { |
||
| 279 | return $this->topicName; |
||
| 280 | } |
||
| 281 | |||
| 282 | public function getLocked(): bool |
||
| 283 | { |
||
| 284 | return $this->locked; |
||
| 285 | } |
||
| 286 | |||
| 287 | public function getNotLocked(): bool |
||
| 288 | { |
||
| 289 | return $this->notLocked; |
||
| 290 | } |
||
| 291 | |||
| 292 | public function getExecutionId(): string |
||
| 293 | { |
||
| 294 | return $this->executionId; |
||
| 295 | } |
||
| 296 | |||
| 297 | public function getProcessInstanceId(): string |
||
| 298 | { |
||
| 299 | return $this->processInstanceId; |
||
| 300 | } |
||
| 301 | |||
| 302 | public function getProcessDefinitionId(): string |
||
| 305 | } |
||
| 306 | |||
| 307 | public function getActivityId(): string |
||
| 308 | { |
||
| 309 | return $this->activityId; |
||
| 310 | } |
||
| 311 | |||
| 312 | public function getSuspensionState(): SuspensionState |
||
| 313 | { |
||
| 314 | return $this->suspensionState; |
||
| 315 | } |
||
| 316 | |||
| 317 | public function getRetriesLeft(): bool |
||
| 318 | { |
||
| 319 | return $this->retriesLeft; |
||
| 320 | } |
||
| 321 | |||
| 322 | public function getNow(): string |
||
| 325 | } |
||
| 326 | } |
||
| 327 |
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