Test Failed
Push — main ( 16fa93...92cbf8 )
by Bingo
06:44
created

SetJobPriorityCmd::createOpLogEntry()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 11
c 0
b 0
f 0
dl 0
loc 13
rs 9.9
cc 1
nc 1
nop 3
1
<?php
2
3
namespace Jabe\Engine\Impl\Cmd;
4
5
use Jabe\Engine\Exception\NotFoundException;
6
use Jabe\Engine\History\UserOperationLogEntryInterface;
7
use Jabe\Engine\Impl\Interceptor\{
8
    CommandInterface,
9
    CommandContext
10
};
11
use Jabe\Engine\Impl\Persistence\Entity\{
12
    JobEntity,
13
    PropertyChange
14
};
15
use Jabe\Engine\Impl\Util\EnsureUtil;
16
17
class SetJobPriorityCmd implements CommandInterface
18
{
19
    public const JOB_PRIORITY_PROPERTY = "priority";
20
    protected $jobId;
21
    protected $priority;
22
23
    public function __construct(string $jobId, int $priority)
24
    {
25
        $this->jobId = $jobId;
26
        $this->priority = $priority;
27
    }
28
29
    public function execute(CommandContext $commandContext)
30
    {
31
        EnsureUtil::ensureNotNull("job id must not be null", "jobId", $this->jobId);
32
33
        $job = $commandContext->getJobManager()->findJobById($this->jobId);
34
        EnsureUtil::ensureNotNull("No job found with id '" . $this->jobId . "'", "job", $job);
35
36
        foreach ($commandContext->getProcessEngineConfiguration()->getCommandCheckers() as $checker) {
0 ignored issues
show
Bug introduced by
The method getCommandCheckers() 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

36
        foreach ($commandContext->getProcessEngineConfiguration()->/** @scrutinizer ignore-call */ getCommandCheckers() as $checker) {

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...
37
            $checker->checkUpdateJob($job);
38
        }
39
40
        $currentPriority = $job->getPriority();
0 ignored issues
show
Unused Code introduced by
The assignment to $currentPriority is dead and can be removed.
Loading history...
41
        $job->setPriority($this->priority);
42
43
        //$this->createOpLogEntry($commandContext, $currentPriority, $job);
44
45
        return null;
46
    }
47
48
    /*protected function createOpLogEntry(CommandContext $commandContext, int $previousPriority, JobEntity $job): void
49
    {
50
        $propertyChange = new PropertyChange(self::JOB_PRIORITY_PROPERTY, $previousPriority, $job->getPriority());
51
        $commandContext
52
            ->getOperationLogManager()
53
            ->logJobOperation(
54
                UserOperationLogEntryInterface::OPERATION_TYPE_SET_PRIORITY,
55
                $job->getId(),
56
                $job->getJobDefinitionId(),
57
                $job->getProcessInstanceId(),
58
                $job->getProcessDefinitionId(),
59
                $job->getProcessDefinitionKey(),
60
                [$propertyChange]
61
            );
62
    }*/
63
}
64