| Total Complexity | 59 |
| Total Lines | 375 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
Complex classes like HistoricJobLogQueryImpl 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 HistoricJobLogQueryImpl, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 22 | class HistoricJobLogQueryImpl extends AbstractQuery implements HistoricJobLogQueryInterface |
||
| 23 | { |
||
| 24 | protected $id; |
||
| 25 | protected $jobId; |
||
| 26 | protected $jobExceptionMessage; |
||
| 27 | protected $jobDefinitionId; |
||
| 28 | protected $jobDefinitionType; |
||
| 29 | protected $jobDefinitionConfiguration; |
||
| 30 | protected $activityIds = []; |
||
| 31 | protected $failedActivityIds = []; |
||
| 32 | protected $executionIds = []; |
||
| 33 | protected $processInstanceId; |
||
| 34 | protected $processDefinitionId; |
||
| 35 | protected $processDefinitionKey; |
||
| 36 | protected $deploymentId; |
||
| 37 | protected $state; |
||
| 38 | protected $jobPriorityHigherThanOrEqual; |
||
| 39 | protected $jobPriorityLowerThanOrEqual; |
||
| 40 | protected $tenantIds = []; |
||
| 41 | protected $isTenantIdSet; |
||
| 42 | protected $hostname; |
||
| 43 | |||
| 44 | public function __construct(CommandExecutorInterface $commandExecutor) |
||
| 45 | { |
||
| 46 | parent::__construct($commandExecutor); |
||
| 47 | } |
||
| 48 | |||
| 49 | public function logId(string $historicJobLogId): HistoricJobLogQueryInterface |
||
| 50 | { |
||
| 51 | EnsureUtil::ensureNotNull(NotValidException::class, "historicJobLogId", $historicJobLogId); |
||
| 52 | $this->id = $historicJobLogId; |
||
| 53 | return $this; |
||
| 54 | } |
||
| 55 | |||
| 56 | public function jobId(string $jobId): HistoricJobLogQueryInterface |
||
| 61 | } |
||
| 62 | |||
| 63 | public function jobExceptionMessage(string $jobExceptionMessage): HistoricJobLogQueryInterface |
||
| 64 | { |
||
| 65 | EnsureUtil::ensureNotNull(NotValidException::class, "jobExceptionMessage", $jobExceptionMessage); |
||
| 66 | $this->jobExceptionMessage = $jobExceptionMessage; |
||
| 67 | return $this; |
||
| 68 | } |
||
| 69 | |||
| 70 | public function jobDefinitionId(string $jobDefinitionId): HistoricJobLogQueryInterface |
||
| 71 | { |
||
| 72 | EnsureUtil::ensureNotNull(NotValidException::class, "jobDefinitionId", $jobDefinitionId); |
||
| 73 | $this->jobDefinitionId = $jobDefinitionId; |
||
| 74 | return $this; |
||
| 75 | } |
||
| 76 | |||
| 77 | public function jobDefinitionType(string $jobDefinitionType): HistoricJobLogQueryInterface |
||
| 78 | { |
||
| 79 | EnsureUtil::ensureNotNull(NotValidException::class, "jobDefinitionType", $jobDefinitionType); |
||
| 80 | $this->jobDefinitionType = $jobDefinitionType; |
||
| 81 | return $this; |
||
| 82 | } |
||
| 83 | |||
| 84 | public function jobDefinitionConfiguration(string $jobDefinitionConfiguration): HistoricJobLogQueryInterface |
||
| 85 | { |
||
| 86 | EnsureUtil::ensureNotNull(NotValidException::class, "jobDefinitionConfiguration", $jobDefinitionConfiguration); |
||
| 87 | $this->jobDefinitionConfiguration = $jobDefinitionConfiguration; |
||
| 88 | return $this; |
||
| 89 | } |
||
| 90 | |||
| 91 | public function activityIdIn(array $activityIds): HistoricJobLogQueryInterface |
||
| 92 | { |
||
| 93 | $activityIdList = CollectionUtil::asArrayList($activityIds); |
||
| 94 | EnsureUtil::ensureNotContainsNull("activityIds", $activityIdList); |
||
| 95 | EnsureUtil::ensureNotContainsEmptyString("activityIds", $activityIdList); |
||
| 96 | $this->activityIds = $activityIds; |
||
| 97 | return $this; |
||
| 98 | } |
||
| 99 | |||
| 100 | public function failedActivityIdIn(array $activityIds): HistoricJobLogQueryInterface |
||
| 101 | { |
||
| 102 | $activityIdList = CollectionUtil::asArrayList($activityIds); |
||
| 103 | EnsureUtil::ensureNotContainsNull("activityIds", $activityIdList); |
||
| 104 | EnsureUtil::ensureNotContainsEmptyString("activityIds", $activityIdList); |
||
| 105 | $this->failedActivityIds = $activityIds; |
||
| 106 | return $this; |
||
| 107 | } |
||
| 108 | |||
| 109 | public function executionIdIn(array $executionIds): HistoricJobLogQueryInterface |
||
| 110 | { |
||
| 111 | $executionIdList = CollectionUtil::asArrayList($executionIds); |
||
| 112 | EnsureUtil::ensureNotContainsNull("executionIds", $executionIdList); |
||
| 113 | EnsureUtil::ensureNotContainsEmptyString("executionIds", $executionIdList); |
||
| 114 | $this->executionIds = $executionIds; |
||
| 115 | return $this; |
||
| 116 | } |
||
| 117 | |||
| 118 | public function processInstanceId(string $processInstanceId): HistoricJobLogQueryInterface |
||
| 119 | { |
||
| 120 | EnsureUtil::ensureNotNull(NotValidException::class, "processInstanceId", $processInstanceId); |
||
| 121 | $this->processInstanceId = $processInstanceId; |
||
| 122 | return $this; |
||
| 123 | } |
||
| 124 | |||
| 125 | public function processDefinitionId(string $processDefinitionId): HistoricJobLogQueryInterface |
||
| 126 | { |
||
| 127 | EnsureUtil::ensureNotNull(NotValidException::class, "processDefinitionId", $processDefinitionId); |
||
| 128 | $this->processDefinitionId = $processDefinitionId; |
||
| 129 | return $this; |
||
| 130 | } |
||
| 131 | |||
| 132 | public function processDefinitionKey(string $processDefinitionKey): HistoricJobLogQueryInterface |
||
| 133 | { |
||
| 134 | EnsureUtil::ensureNotNull(NotValidException::class, "processDefinitionKey", $processDefinitionKey); |
||
| 135 | $this->processDefinitionKey = $processDefinitionKey; |
||
| 136 | return $this; |
||
| 137 | } |
||
| 138 | |||
| 139 | public function deploymentId(string $deploymentId): HistoricJobLogQueryInterface |
||
| 140 | { |
||
| 141 | EnsureUtil::ensureNotNull(NotValidException::class, "deploymentId", $deploymentId); |
||
| 142 | $this->deploymentId = $deploymentId; |
||
| 143 | return $this; |
||
| 144 | } |
||
| 145 | |||
| 146 | public function jobPriorityHigherThanOrEquals(int $priority): HistoricJobLogQueryInterface |
||
| 147 | { |
||
| 148 | $this->jobPriorityHigherThanOrEqual = $priority; |
||
| 149 | return $this; |
||
| 150 | } |
||
| 151 | |||
| 152 | public function jobPriorityLowerThanOrEquals(int $priority): HistoricJobLogQueryInterface |
||
| 153 | { |
||
| 154 | $this->jobPriorityLowerThanOrEqual = $priority; |
||
| 155 | return $this; |
||
| 156 | } |
||
| 157 | |||
| 158 | public function tenantIdIn(array $tenantIds): HistoricJobLogQueryInterface |
||
| 159 | { |
||
| 160 | EnsureUtil::ensureNotNull("tenantIds", "tenantIds", $tenantIds); |
||
| 161 | $this->tenantIds = $tenantIds; |
||
| 162 | $this->isTenantIdSet = true; |
||
| 163 | return $this; |
||
| 164 | } |
||
| 165 | |||
| 166 | public function withoutTenantId(): HistoricJobLogQueryInterface |
||
| 167 | { |
||
| 168 | $this->tenantIds = null; |
||
| 169 | $this->isTenantIdSet = true; |
||
| 170 | return $this; |
||
| 171 | } |
||
| 172 | |||
| 173 | public function hostname(string $hostname): HistoricJobLogQueryInterface |
||
| 174 | { |
||
| 175 | EnsureUtil::ensureNotEmpty("hostName", "hostname", $hostname); |
||
| 176 | $this->hostname = $hostname; |
||
| 177 | return $this; |
||
| 178 | } |
||
| 179 | |||
| 180 | public function creationLog(): HistoricJobLogQueryInterface |
||
| 181 | { |
||
| 182 | $this->setState(JobStateImpl::created()); |
||
| 183 | return $this; |
||
| 184 | } |
||
| 185 | |||
| 186 | public function failureLog(): HistoricJobLogQueryInterface |
||
| 187 | { |
||
| 188 | $this->setState(JobStateImpl::failed()); |
||
| 189 | return $this; |
||
| 190 | } |
||
| 191 | |||
| 192 | public function successLog(): HistoricJobLogQueryInterface |
||
| 193 | { |
||
| 194 | $this->setState(JobStateImpl::successful()); |
||
| 195 | return $this; |
||
| 196 | } |
||
| 197 | |||
| 198 | public function deletionLog(): HistoricJobLogQueryInterface |
||
| 199 | { |
||
| 200 | $this->setState(JobStateImpl::deleted()); |
||
| 201 | return $this; |
||
| 202 | } |
||
| 203 | |||
| 204 | protected function hasExcludingConditions(): bool |
||
| 205 | { |
||
| 206 | return parent::hasExcludingConditions() |
||
| 207 | || CompareUtil::areNotInAscendingOrder($this->jobPriorityHigherThanOrEqual, $this->jobPriorityLowerThanOrEqual); |
||
| 208 | } |
||
| 209 | |||
| 210 | public function orderByTimestamp(): HistoricJobLogQueryInterface |
||
| 211 | { |
||
| 212 | $this->orderBy(HistoricJobLogQueryProperty::timestamp()); |
||
| 213 | return $this; |
||
| 214 | } |
||
| 215 | |||
| 216 | public function orderByJobId(): HistoricJobLogQueryInterface |
||
| 217 | { |
||
| 218 | $this->orderBy(HistoricJobLogQueryProperty::jobId()); |
||
| 219 | return $this; |
||
| 220 | } |
||
| 221 | |||
| 222 | public function orderByJobDueDate(): HistoricJobLogQueryInterface |
||
| 223 | { |
||
| 224 | $this->orderBy(HistoricJobLogQueryPropert::duedate()); |
||
| 225 | return $this; |
||
| 226 | } |
||
| 227 | |||
| 228 | public function orderByJobRetries(): HistoricJobLogQueryInterface |
||
| 229 | { |
||
| 230 | $this->orderBy(HistoricJobLogQueryProperty::retries()); |
||
| 231 | return $this; |
||
| 232 | } |
||
| 233 | |||
| 234 | public function orderByJobPriority(): HistoricJobLogQueryInterface |
||
| 235 | { |
||
| 236 | $this->orderBy(HistoricJobLogQueryProperty::priority()); |
||
| 237 | return $this; |
||
| 238 | } |
||
| 239 | |||
| 240 | public function orderByJobDefinitionId(): HistoricJobLogQueryInterface |
||
| 241 | { |
||
| 242 | $this->orderBy(HistoricJobLogQueryProperty::jobDefinitionId()); |
||
| 243 | return $this; |
||
| 244 | } |
||
| 245 | |||
| 246 | public function orderByActivityId(): HistoricJobLogQueryInterface |
||
| 247 | { |
||
| 248 | $this->orderBy(HistoricJobLogQueryProperty::activityId()); |
||
| 249 | return $this; |
||
| 250 | } |
||
| 251 | |||
| 252 | public function orderByExecutionId(): HistoricJobLogQueryInterface |
||
| 253 | { |
||
| 254 | $this->orderBy(HistoricJobLogQueryProperty::executionId()); |
||
| 255 | return $this; |
||
| 256 | } |
||
| 257 | |||
| 258 | public function orderByProcessInstanceId(): HistoricJobLogQueryInterface |
||
| 259 | { |
||
| 260 | $this->orderBy(HistoricJobLogQueryProperty::processInstanceId()); |
||
| 261 | return $this; |
||
| 262 | } |
||
| 263 | |||
| 264 | public function orderByProcessDefinitionId(): HistoricJobLogQueryInterface |
||
| 265 | { |
||
| 266 | $this->orderBy(HistoricJobLogQueryProperty::processDefinitionId()); |
||
| 267 | return $this; |
||
| 268 | } |
||
| 269 | |||
| 270 | public function orderByProcessDefinitionKey(): HistoricJobLogQueryInterface |
||
| 271 | { |
||
| 272 | $this->orderBy(HistoricJobLogQueryProperty::processDefinitionKey()); |
||
| 273 | return $this; |
||
| 274 | } |
||
| 275 | |||
| 276 | public function orderByDeploymentId(): HistoricJobLogQueryInterface |
||
| 277 | { |
||
| 278 | $this->orderBy(HistoricJobLogQueryProperty::deploymentId()); |
||
| 279 | return $this; |
||
| 280 | } |
||
| 281 | |||
| 282 | public function orderPartiallyByOccurrence(): HistoricJobLogQueryInterface |
||
| 283 | { |
||
| 284 | $this->orderBy(HistoricJobLogQueryProperty::sequenceCounter()); |
||
| 285 | return $this; |
||
| 286 | } |
||
| 287 | |||
| 288 | public function orderByTenantId(): HistoricJobLogQueryInterface |
||
| 289 | { |
||
| 290 | return orderBy(HistoricJobLogQueryProperty::tenantId()); |
||
| 291 | } |
||
| 292 | |||
| 293 | public function orderByHostname(): HistoricJobLogQueryInterface |
||
| 294 | { |
||
| 295 | return orderBy(HistoricJobLogQueryProperty::hostname()); |
||
| 296 | } |
||
| 297 | |||
| 298 | public function executeCount(CommandContext $commandContext): int |
||
| 299 | { |
||
| 300 | $this->checkQueryOk(); |
||
| 301 | return $commandContext |
||
| 302 | ->getHistoricJobLogManager() |
||
| 303 | ->findHistoricJobLogsCountByQueryCriteria($this); |
||
| 304 | } |
||
| 305 | |||
| 306 | public function executeList(CommandContext $commandContext, Page $page): array |
||
| 307 | { |
||
| 308 | $this->checkQueryOk(); |
||
| 309 | return $commandContext |
||
| 310 | ->getHistoricJobLogManager() |
||
| 311 | ->findHistoricJobLogsByQueryCriteria($this, $page); |
||
| 312 | } |
||
| 313 | |||
| 314 | public function isTenantIdSet(): bool |
||
| 315 | { |
||
| 316 | return $this->isTenantIdSet; |
||
| 317 | } |
||
| 318 | |||
| 319 | public function getJobId(): string |
||
| 320 | { |
||
| 321 | return $this->jobId; |
||
| 322 | } |
||
| 323 | |||
| 324 | public function getJobExceptionMessage(): string |
||
| 325 | { |
||
| 326 | return $this->jobExceptionMessage; |
||
| 327 | } |
||
| 328 | |||
| 329 | public function getJobDefinitionId(): string |
||
| 332 | } |
||
| 333 | |||
| 334 | public function getJobDefinitionType(): string |
||
| 335 | { |
||
| 336 | return $this->jobDefinitionType; |
||
| 337 | } |
||
| 338 | |||
| 339 | public function getJobDefinitionConfiguration(): string |
||
| 340 | { |
||
| 341 | return $this->jobDefinitionConfiguration; |
||
| 342 | } |
||
| 343 | |||
| 344 | public function getActivityIds(): array |
||
| 345 | { |
||
| 346 | return $this->activityIds; |
||
| 347 | } |
||
| 348 | |||
| 349 | public function getFailedActivityIds(): array |
||
| 350 | { |
||
| 351 | return $this->failedActivityIds; |
||
| 352 | } |
||
| 353 | |||
| 354 | public function getExecutionIds(): array |
||
| 355 | { |
||
| 356 | return $this->executionIds; |
||
| 357 | } |
||
| 358 | |||
| 359 | public function getProcessInstanceId(): string |
||
| 360 | { |
||
| 361 | return $this->processInstanceId; |
||
| 362 | } |
||
| 363 | |||
| 364 | public function getProcessDefinitionId(): string |
||
| 365 | { |
||
| 366 | return $this->processDefinitionId; |
||
| 367 | } |
||
| 368 | |||
| 369 | public function getProcessDefinitionKey(): string |
||
| 370 | { |
||
| 371 | return $this->processDefinitionKey; |
||
| 372 | } |
||
| 373 | |||
| 374 | public function getDeploymentId(): string |
||
| 377 | } |
||
| 378 | |||
| 379 | public function getState(): JobStateInterface |
||
| 380 | { |
||
| 381 | return $this->state; |
||
| 382 | } |
||
| 383 | |||
| 384 | public function getTenantIds(): array |
||
| 385 | { |
||
| 386 | return $this->tenantIds; |
||
| 387 | } |
||
| 388 | |||
| 389 | public function getHostname(): string |
||
| 392 | } |
||
| 393 | |||
| 394 | protected function setState(JobStateInterface $state): void |
||
| 395 | { |
||
| 396 | $this->state = $state; |
||
| 397 | } |
||
| 398 | } |
||
| 399 |
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