Test Failed
Push — main ( fc8ba5...9083af )
by Bingo
05:27
created

UpdateProcessInstancesSuspendStateJobHandler   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Importance

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

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getType() 0 3 1
A createJobConfiguration() 0 3 1
A getJobDeclaration() 0 6 2
A execute() 0 15 1
A getJsonConverterInstance() 0 3 1
1
<?php
2
3
namespace Jabe\Engine\Impl\Batch\RemovalTime;
4
5
use Jabe\Engine\Batch\BatchInterface;
6
use Jabe\Engine\Impl\UpdateProcessInstancesSuspensionStateBuilderImpl;
7
use Jabe\Engine\Impl\Batch\{
8
    AbstractBatchJobHandler,
9
    BatchJobConfiguration,
10
    BatchJobContext,
11
    BatchJobDeclaration
12
};
13
use Jabe\Engine\Impl\Cmd\UpdateProcessInstancesSuspendStateCmd;
14
use Jabe\Engine\Impl\Interceptor\{
15
    CommandContext,
16
    CommandExecutorInterface
17
};
18
use Jabe\Engine\Impl\JobExecutor\JobDeclaration;
19
use Jabe\Engine\Impl\Json\JsonObjectConverter;
20
use Jabe\Engine\Impl\Persistence\Entity\{
21
    ByteArrayEntity,
22
    ExecutionEntity,
23
    MessageEntity
24
};
25
26
class UpdateProcessInstancesSuspendStateJobHandler extends AbstractBatchJobHandler
27
{
28
    public static $JOB_DECLARATION;
29
30
    public function getType(): string
31
    {
32
        return BatchInterface::TYPE_PROCESS_INSTANCE_UPDATE_SUSPENSION_STATE;
33
    }
34
35
    protected function getJsonConverterInstance(): JsonObjectConverter
36
    {
37
        return UpdateProcessInstancesSuspendStateBatchConfigurationJsonConverter::instance();
38
    }
39
40
    public function getJobDeclaration(): JobDeclaration
41
    {
42
        if (self::$JOB_DECLARATION === null) {
43
            self::$JOB_DECLARATION = new BatchJobDeclaration(BatchInterface::TYPE_PROCESS_INSTANCE_UPDATE_SUSPENSION_STATE);
44
        }
45
        return self::$JOB_DECLARATION;
46
    }
47
48
    protected function createJobConfiguration(BatchConfiguration $configuration, array $processIdsForJob): BatchConfiguration
49
    {
50
        return new UpdateProcessInstancesSuspendStateBatchConfiguration($processIdsForJob, $configuration->getSuspended());
51
    }
52
53
    public function execute(BatchJobConfiguration $configuration, ExecutionEntity $execution, CommandContext $commandContext, string $tenantId = null)
54
    {
55
        $configurationEntity = $commandContext
56
            ->getDbEntityManager()
57
            ->selectById(ByteArrayEntity::class, $configuration->getConfigurationByteArrayId());
58
59
        $batchConfiguration = $this->readConfiguration($configurationEntity->getBytes());
0 ignored issues
show
Bug introduced by
It seems like $configurationEntity->getBytes() can also be of type null; however, parameter $serializedConfiguration of Jabe\Engine\Impl\Batch\A...er::readConfiguration() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

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

59
        $batchConfiguration = $this->readConfiguration(/** @scrutinizer ignore-type */ $configurationEntity->getBytes());
Loading history...
60
61
        $commandExecutor = $commandContext->getProcessEngineConfiguration()
62
            ->getCommandExecutorTxRequired();
0 ignored issues
show
Bug introduced by
The method getCommandExecutorTxRequired() does not exist on Jabe\Engine\Impl\Cfg\Pro...EngineConfigurationImpl. ( Ignorable by Annotation )

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

62
            ->/** @scrutinizer ignore-call */ getCommandExecutorTxRequired();

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...
63
        $commandContext->executeWithOperationLogPrevented(
64
            new UpdateProcessInstancesSuspendStateCmd(
65
                $commandExecutor,
66
                new UpdateProcessInstancesSuspensionStateBuilderImpl($batchConfiguration->getIds()),
67
                $batchConfiguration->getSuspended()
0 ignored issues
show
Bug introduced by
The method getSuspended() does not exist on Jabe\Engine\Impl\Batch\BatchConfiguration. It seems like you code against a sub-type of Jabe\Engine\Impl\Batch\BatchConfiguration such as Jabe\Engine\Impl\Batch\U...StateBatchConfiguration. ( Ignorable by Annotation )

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

67
                $batchConfiguration->/** @scrutinizer ignore-call */ 
68
                                     getSuspended()
Loading history...
68
            )
69
        );
70
    }
71
}
72