deleteProcessDefinitionCmd()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 27
Code Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 18
dl 0
loc 27
rs 9.6666
c 0
b 0
f 0
cc 2
nc 2
nop 5
1
<?php
2
3
namespace Jabe\Impl\Cmd;
4
5
use Jabe\History\UserOperationLogEntryInterface;
6
use Jabe\Impl\Interceptor\{
7
    CommandInterface,
8
    CommandContext
9
};
10
use Jabe\Impl\Persistence\Entity\{
11
    ProcessDefinitionManager,
12
    PropertyChange,
13
    UserOperationLogManager
14
};
15
use Jabe\Impl\Util\EnsureUtil;
16
17
abstract class AbstractDeleteProcessDefinitionCmd implements CommandInterface, \Serializable
18
{
19
    protected $cascade;
20
    protected $skipCustomListeners;
21
    protected $skipIoMappings;
22
23
    public function serialize()
24
    {
25
        return json_encode([
26
            'cascade' => $this->cascade,
27
            'skipCustomListeners' => $this->skipCustomListeners,
28
            'skipIoMappings' => $this->skipIoMappings
29
        ]);
30
    }
31
32
    public function unserialize($data)
33
    {
34
        $json = json_decode($data);
35
        $this->cascade = $json->cascade;
36
        $this->skipCustomListeners = $json->skipCustomListeners;
37
        $this->skipIoMappings = $json->skipIoMappings;
38
    }
39
40
    protected function deleteProcessDefinitionCmd(CommandContext $commandContext, string $processDefinitionId, bool $cascade, bool $skipCustomListeners, bool $skipIoMappings): void
0 ignored issues
show
Unused Code introduced by
The parameter $skipCustomListeners is not used and could be removed. ( Ignorable by Annotation )

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

40
    protected function deleteProcessDefinitionCmd(CommandContext $commandContext, string $processDefinitionId, bool $cascade, /** @scrutinizer ignore-unused */ bool $skipCustomListeners, bool $skipIoMappings): void

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $skipIoMappings is not used and could be removed. ( Ignorable by Annotation )

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

40
    protected function deleteProcessDefinitionCmd(CommandContext $commandContext, string $processDefinitionId, bool $cascade, bool $skipCustomListeners, /** @scrutinizer ignore-unused */ bool $skipIoMappings): void

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
41
    {
42
        EnsureUtil::ensureNotNull("processDefinitionId", $processDefinitionId);
43
44
        $processDefinition = $commandContext->getProcessDefinitionManager()
45
            ->findLatestProcessDefinitionById($processDefinitionId);
46
        EnsureUtil::ensureNotNull(
47
            "No process definition found with id '" . $processDefinitionId . "'",
48
            "processDefinition",
49
            $processDefinition
50
        );
51
52
        $commandCheckers = $commandContext->getProcessEngineConfiguration()->getCommandCheckers();
0 ignored issues
show
Bug introduced by
The method getCommandCheckers() does not exist on Jabe\Impl\Cfg\ProcessEngineConfigurationImpl. ( Ignorable by Annotation )

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

52
        $commandCheckers = $commandContext->getProcessEngineConfiguration()->/** @scrutinizer ignore-call */ getCommandCheckers();

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...
53
        foreach ($commandCheckers as $checker) {
54
            $checker->checkDeleteProcessDefinitionById($processDefinitionId);
55
        }
56
57
        $userOperationLogManager = $commandContext->getOperationLogManager();
58
        $userOperationLogManager->logProcessDefinitionOperation(
59
            UserOperationLogEntryInterface::OPERATION_TYPE_DELETE,
60
            $processDefinitionId,
61
            $processDefinition->getKey(),
62
            new PropertyChange("cascade", false, $cascade)
63
        );
64
65
        $definitionManager = $commandContext->getProcessDefinitionManager();
66
        $definitionManager->deleteProcessDefinition($processDefinition, $processDefinitionId, $cascade, $cascade, $this->skipCustomListeners, $this->skipIoMappings);
67
    }
68
}
69