Test Failed
Push — main ( 5af89f...c76fcf )
by Bingo
05:51
created

ExternalTaskServiceImpl::setRetries()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 8
rs 10
cc 2
nc 2
nop 3
1
<?php
2
3
namespace Jabe\Engine\Impl;
4
5
use Jabe\Engine\ExternalTaskServiceInterface;
6
use Jabe\Engine\Batch\BatchInterface;
7
use Jabe\Engine\ExternalTask\{
8
    ExternalTaskQueryInterface,
9
    ExternalTaskQueryBuilderInterface,
10
    UpdateExternalTaskRetriesSelectBuilderInterface
11
};
12
use Jabe\Engine\Impl\Cmd\{
13
    LockExternalTaskCmd,
14
    CompleteExternalTaskCmd,
15
    HandleExternalTaskFailureCmd,
16
    HandleExternalTaskBpmnErrorCmd,
17
    UnlockExternalTaskCmd,
18
    SetExternalTaskRetriesCmd,
19
    SetExternalTaskPriorityCmd,
20
    GetTopicNamesCmd,
21
    GetExternalTaskErrorDetailsCmd,
22
    ExtendLockOnExternalTaskCmd
23
};
24
use Jabe\Engine\Impl\ExternalTask\ExternalTaskQueryTopicBuilderImpl;
25
26
class ExternalTaskServiceImpl extends ServiceImpl implements ExternalTaskServiceInterface
27
{
28
    public function fetchAndLock(int $maxTasks, string $workerId, bool $usePriority = false): ExternalTaskQueryBuilderInterface
29
    {
30
        return new ExternalTaskQueryTopicBuilderImpl($this->commandExecutor, $workerId, $maxTasks, $usePriority);
31
    }
32
33
    public function lock(string $externalTaskId, string $workerId, int $lockDuration): void
34
    {
35
        $this->commandExecutor->execute(new LockExternalTaskCmd($externalTaskId, $workerId, $lockDuration));
36
    }
37
38
    public function complete(string $externalTaskId, string $workerId, array $variables = [], array $localVariables = []): void
39
    {
40
        $this->commandExecutor->execute(new CompleteExternalTaskCmd($externalTaskId, $workerId, $variables, $localVariables));
41
    }
42
43
    public function handleFailure(string $externalTaskId, string $workerId, string $errorMessage, string $errorDetails, int $retries, int $retryDuration, array $variables = [], array $localVariables = []): void
44
    {
45
        $this->commandExecutor->execute(new HandleExternalTaskFailureCmd(externalTaskId, workerId, errorMessage, errorDetails, retries, retryDuration, variables, localVariables));
0 ignored issues
show
Bug introduced by
The constant Jabe\Engine\Impl\localVariables was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
Bug introduced by
The constant Jabe\Engine\Impl\errorDetails was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
Bug introduced by
The constant Jabe\Engine\Impl\variables was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
Bug introduced by
The constant Jabe\Engine\Impl\errorMessage was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
Bug introduced by
The constant Jabe\Engine\Impl\retryDuration was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
Bug introduced by
The constant Jabe\Engine\Impl\retries was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
Bug introduced by
The constant Jabe\Engine\Impl\externalTaskId was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
Bug introduced by
The constant Jabe\Engine\Impl\workerId was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
46
    }
47
48
    public function handleBpmnError(string $externalTaskId, string $workerId, string $errorCode, string $errorMessage = null, array $variables = []): void
49
    {
50
        $this->commandExecutor->execute(new HandleExternalTaskBpmnErrorCmd($externalTaskId, $workerId, $errorCode, $errorMessage, $variables));
51
    }
52
53
    public function unlock(string $externalTaskId): void
54
    {
55
        $this->commandExecutor->execute(new UnlockExternalTaskCmd($externalTaskId));
56
    }
57
58
    public function setPriority(string $externalTaskId, int $priority): void
59
    {
60
        $this->commandExecutor->execute(new SetExternalTaskPriorityCmd($externalTaskId, $priority));
61
    }
62
63
    public function createExternalTaskQuery(): ExternalTaskQueryInterface
64
    {
65
        return new ExternalTaskQueryImpl($this->commandExecutor);
66
    }
67
68
    public function getTopicNames(bool $withLockedTasks = false, bool $withUnlockedTasks = false, bool $withRetriesLeft = false): array
69
    {
70
        return $this->commandExecutor->execute(new GetTopicNamesCmd($withLockedTasks, $withUnlockedTasks, $withRetriesLeft));
71
    }
72
73
    public function getExternalTaskErrorDetails(string $externalTaskId): string
74
    {
75
        return $this->commandExecutor->execute(new GetExternalTaskErrorDetailsCmd($externalTaskId));
76
    }
77
78
    public function setRetries($externalTaskIdOrIds, int $retries, bool $writeUserOperationLog = true): void
79
    {
80
        if (is_array($externalTaskIdOrIds)) {
81
            $this->updateRetries()
82
                ->externalTaskIds($externalTaskIdOrIds)
0 ignored issues
show
Bug introduced by
The method externalTaskIds() does not exist on Jabe\Engine\ExternalTask...sSelectBuilderInterface. It seems like you code against a sub-type of Jabe\Engine\ExternalTask...sSelectBuilderInterface such as Jabe\Engine\Impl\Cmd\Upd...lTaskRetriesBuilderImpl. ( Ignorable by Annotation )

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

82
                ->/** @scrutinizer ignore-call */ externalTaskIds($externalTaskIdOrIds)
Loading history...
83
                ->set($retries);
84
        } else {
85
            $this->commandExecutor->execute(new SetExternalTaskRetriesCmd($externalTaskIdOrIds, $retries, $writeUserOperationLog));
86
        }
87
    }
88
89
    public function setRetriesAsync(array $externalTaskIds, ExternalTaskQueryInterface $externalTaskQuery, int $retries): BatchInterface
90
    {
91
        return $this->updateRetries()
92
            ->externalTaskIds($externalTaskIds)
93
            ->externalTaskQuery($externalTaskQuery)
94
            ->setAsync($retries);
95
    }
96
97
    public function updateRetries(): UpdateExternalTaskRetriesSelectBuilderInterface
98
    {
99
        return new UpdateExternalTaskRetriesBuilderImpl($commandExecutor);
0 ignored issues
show
Bug introduced by
The type Jabe\Engine\Impl\UpdateE...lTaskRetriesBuilderImpl 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...
Comprehensibility Best Practice introduced by
The variable $commandExecutor seems to be never defined.
Loading history...
100
    }
101
102
    public function extendLock(string $externalTaskId, string $workerId, int $lockDuration): void
103
    {
104
        $this->commandExecutor->execute(new ExtendLockOnExternalTaskCmd($externalTaskId, $workerId, $lockDuration));
105
    }
106
}
107