Passed
Push — main ( 6fd589...d01f4c )
by Bingo
05:51
created

SetExternalTaskRetriesJobHandler   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
eloc 18
c 1
b 0
f 0
dl 0
loc 45
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getJobDeclaration() 0 6 2
A getType() 0 3 1
A execute() 0 18 1
A createJobConfiguration() 0 3 1
A getJsonConverterInstance() 0 3 1
1
<?php
2
3
namespace Jabe\Engine\Impl\Batch\ExternalTask;
4
5
use Jabe\Engine\Batch\BatchInterface;
6
use Jabe\Engine\Impl\Batch\{
7
    AbstractBatchJobHandler,
0 ignored issues
show
Bug introduced by
The type Jabe\Engine\Impl\Batch\AbstractBatchJobHandler was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
    BatchJobConfiguration,
0 ignored issues
show
Bug introduced by
The type Jabe\Engine\Impl\Batch\BatchJobConfiguration was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
9
    BatchJobContext,
0 ignored issues
show
Bug introduced by
The type Jabe\Engine\Impl\Batch\BatchJobContext was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
10
    BatchJobDeclaration
0 ignored issues
show
Bug introduced by
The type Jabe\Engine\Impl\Batch\BatchJobDeclaration was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
11
};
12
use Jabe\Engine\Impl\Cmd\{
13
    SetExternalTasksRetriesCmd,
14
    UpdateExternalTaskRetriesBuilderImpl
15
};
16
use Jabe\Engine\Impl\Interceptor\CommandContext;
17
use Jabe\Engine\Impl\JobExecutor\{
18
    JobDeclaration,
19
    JobHandlerConfigurationInterface
20
};
21
use Jabe\Engine\Impl\Persistence\Entity\{
22
    ByteArrayEntity,
23
    ExecutionEntity,
24
    MessageEntity
25
};
26
27
class SetExternalTaskRetriesJobHandler extends AbstractBatchJobHandler
28
{
29
    public static $JOB_DECLARATION;
30
31
    public function getType(): string
32
    {
33
        return BatchInterface::TYPE_SET_EXTERNAL_TASK_RETRIES;
34
    }
35
36
    public function getJobDeclaration(): JobDeclaration
37
    {
38
        if (self::$JOB_DECLARATION == null) {
39
            self::$JOB_DECLARATION = new BatchJobDeclaration(BatchInterface::TYPE_SET_EXTERNAL_TASK_RETRIES);
40
        }
41
        return self::$JOB_DECLARATION;
42
    }
43
44
    public function execute(JobHandlerConfigurationInterface $configuration, ExecutionEntity $execution, CommandContext $commandContext, ?string $tenantId): void
45
    {
46
        $configurationEntity = $commandContext
47
            ->getDbEntityManager()
48
            ->selectById(ByteArrayEntity::class, $configuration->getConfigurationByteArrayId());
0 ignored issues
show
Bug introduced by
The method getConfigurationByteArrayId() does not exist on Jabe\Engine\Impl\JobExec...rConfigurationInterface. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

48
            ->selectById(ByteArrayEntity::class, $configuration->/** @scrutinizer ignore-call */ getConfigurationByteArrayId());

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
49
50
        $batchConfiguration = $this->readConfiguration($configurationEntity->getBytes());
51
52
        $commandContext->executeWithOperationLogPrevented(
53
            new SetExternalTasksRetriesCmd(
54
                new UpdateExternalTaskRetriesBuilderImpl(
55
                    $batchConfiguration->getIds(),
56
                    $batchConfiguration->getRetries()
57
                )
58
            )
59
        );
60
61
        $commandContext->getByteArrayManager()->delete($configurationEntity);
62
    }
63
64
    protected function createJobConfiguration(SetRetriesBatchConfiguration $configuration, array $processIdsForJob): SetRetriesBatchConfiguration
0 ignored issues
show
Bug introduced by
The type Jabe\Engine\Impl\Batch\E...triesBatchConfiguration was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
65
    {
66
        return new SetRetriesBatchConfiguration($processIdsForJob, $configuration->getRetries());
67
    }
68
69
    protected function getJsonConverterInstance(): SetExternalTaskRetriesBatchConfigurationJsonConverter
70
    {
71
        return SetExternalTaskRetriesBatchConfigurationJsonConverter::instance();
72
    }
73
}
74