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

EventSubscriptionQueryImpl::serialize()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
c 1
b 0
f 0
dl 0
loc 12
rs 9.9332
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Jabe\Engine\Impl;
4
5
use Jabe\Engine\Impl\Interceptor\{
6
    CommandContext,
7
    CommandExecutorInterface
8
};
9
use Jabe\Engine\Impl\Util\EnsureUtil;
0 ignored issues
show
Bug introduced by
The type Jabe\Engine\Impl\Util\EnsureUtil 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
use Jabe\Engine\Runtime\EventSubscriptionQueryInterface;
11
12
class EventSubscriptionQueryImpl extends AbstractQuery implements \Serializable, EventSubscriptionQueryInterface
13
{
14
    protected $eventSubscriptionId;
15
    protected $eventName;
16
    protected $eventType;
17
    protected $executionId;
18
    protected $processInstanceId;
19
    protected $activityId;
20
21
    protected $isTenantIdSet = false;
22
    protected $tenantIds = [];
23
    protected $includeEventSubscriptionsWithoutTenantId = false;
24
25
    public function __construct(CommandExecutorInterface $commandExecutor)
26
    {
27
        parent::__construct($commandExecutor);
28
    }
29
30
    public function serialize()
31
    {
32
        return json_encode([
33
            'eventSubscriptionId' => $this->eventSubscriptionId,
34
            'eventName' => $this->eventName,
35
            'eventType' => $this->eventType,
36
            'executionId' => $this->executionId,
37
            'processInstanceId' => $this->processInstanceId,
38
            'activityId' => $this->activityId,
39
            'isTenantIdSet' => $this->isTenantIdSet,
40
            'tenantIds' => $this->tenantIds,
41
            'includeEventSubscriptionsWithoutTenantId' => $this->includeEventSubscriptionsWithoutTenantId
42
        ]);
43
    }
44
45
    public function unserialize($data)
46
    {
47
        $json = json_decode($data);
48
        $this->eventSubscriptionId = $json->eventSubscriptionId;
49
        $this->eventName = $json->eventName;
50
        $this->eventType = $json->eventType;
51
        $this->executionId = $json->executionId;
52
        $this->processInstanceId = $json->processInstanceId;
53
        $this->activityId = $json->activityId;
54
        $this->isTenantIdSet = $json->isTenantIdSet;
55
        $this->tenantIds = $json->tenantIds;
56
        $this->includeEventSubscriptionsWithoutTenantId = $json->includeEventSubscriptionsWithoutTenantId;
57
    }
58
59
    public function eventSubscriptionId(string $id): EventSubscriptionQueryInterface
60
    {
61
        EnsureUtil::ensureNotNull("event subscription id", "id", $id);
62
        $this->eventSubscriptionId = $id;
63
        return $this;
64
    }
65
66
    public function eventName(string $eventName): EventSubscriptionQueryInterface
67
    {
68
        EnsureUtil::ensureNotNull("event name", "eventName", $eventName);
69
        $this->eventName = $eventName;
70
        return $this;
71
    }
72
73
    public function executionId(string $executionId): EventSubscriptionQueryInterface
74
    {
75
        EnsureUtil::ensureNotNull("execution id", "executionId", $executionId);
76
        $this->executionId = $executionId;
77
        return $this;
78
    }
79
80
    public function processInstanceId(string $processInstanceId): EventSubscriptionQueryInterface
81
    {
82
        EnsureUtil::ensureNotNull("process instance id", "processInstanceId", $processInstanceId);
83
        $this->processInstanceId = $processInstanceId;
84
        return $this;
85
    }
86
87
    public function activityId(string $activityId): EventSubscriptionQueryInterface
88
    {
89
        EnsureUtil::ensureNotNull("activity id", "activityId", $activityId);
90
        $this->activityId = $activityId;
91
        return $this;
92
    }
93
94
    public function tenantIdIn(array $tenantIds): EventSubscriptionQueryInterface
95
    {
96
        EnsureUtil::ensureNotNull("tenantIds", "tenantIds", $tenantIds);
97
        $this->tenantIds = $tenantIds;
98
        $this->isTenantIdSet = true;
99
        return $this;
100
    }
101
102
    public function withoutTenantId(): EventSubscriptionQueryInterface
103
    {
104
        $this->isTenantIdSet = true;
105
        $this->tenantIds = null;
106
        return $this;
107
    }
108
109
    public function includeEventSubscriptionsWithoutTenantId(): EventSubscriptionQueryInterface
110
    {
111
        $this->includeEventSubscriptionsWithoutTenantId  = true;
112
        return $this;
113
    }
114
115
    public function eventType(string $eventType): EventSubscriptionQueryInterface
116
    {
117
        EnsureUtil::ensureNotNull("event type", "eventType", $eventType);
118
        $this->eventType = $eventType;
119
        return $this;
120
    }
121
122
    public function orderByCreated(): EventSubscriptionQueryInterface
123
    {
124
        return $this->orderBy(EventSubscriptionQueryProperty::created());
125
    }
126
127
    public function orderByTenantId(): EventSubscriptionQueryInterface
128
    {
129
        return $this->orderBy(EventSubscriptionQueryProperty::tenantId());
130
    }
131
132
    //results //////////////////////////////////////////
133
134
    public function executeCount(CommandContext $commandContext): int
135
    {
136
        $this->checkQueryOk();
137
        return $commandContext
138
            ->getEventSubscriptionManager()
139
            ->findEventSubscriptionCountByQueryCriteria($this);
140
    }
141
142
    public function executeList(CommandContext $commandContext, Page $page): array
0 ignored issues
show
Bug introduced by
The type Jabe\Engine\Impl\Page 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...
143
    {
144
        $this->checkQueryOk();
145
        return $commandContext
146
            ->getEventSubscriptionManager()
147
            ->findEventSubscriptionsByQueryCriteria($this, $page);
148
    }
149
150
    //getters //////////////////////////////////////////
151
152
    public function getEventSubscriptionId(): string
153
    {
154
        return $this->eventSubscriptionId;
155
    }
156
157
    public function getEventName(): string
158
    {
159
        return $this->eventName;
160
    }
161
162
    public function getEventType(): string
163
    {
164
        return $this->eventType;
165
    }
166
167
    public function getExecutionId(): string
168
    {
169
        return $this->executionId;
170
    }
171
172
    public function getProcessInstanceId(): string
173
    {
174
        return $this->processInstanceId;
175
    }
176
177
    public function getActivityId(): string
178
    {
179
        return $this->activityId;
180
    }
181
}
182