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

DeploymentQueryImpl::serialize()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
c 1
b 0
f 0
dl 0
loc 13
rs 9.9
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\{
10
    CompareUtil,
0 ignored issues
show
Bug introduced by
The type Jabe\Engine\Impl\Util\CompareUtil 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...
11
    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...
12
};
13
use Jabe\Engine\Repository\DeploymentQueryInterface;
14
15
class DeploymentQueryImpl extends AbstractQuery implements DeploymentQueryInterface, \Serializable
16
{
17
    protected $deploymentId;
18
    protected $name;
19
    protected $nameLike;
20
    protected $sourceQueryParamEnabled;
21
    protected $source;
22
    protected $deploymentBefore;
23
    protected $deploymentAfter;
24
25
    protected $isTenantIdSet = false;
26
    protected $tenantIds = [];
27
    protected $includeDeploymentsWithoutTenantId = false;
28
29
    public function __construct(CommandExecutorInterface $commandExecutor)
30
    {
31
        parent::__construct($commandExecutor);
32
    }
33
34
    public function serialize()
35
    {
36
        return json_encode([
37
            'deploymentId' => $this->deploymentId,
38
            'name' => $this->name,
39
            'nameLike' => $this->nameLike,
40
            'sourceQueryParamEnabled' => $this->sourceQueryParamEnabled,
41
            'source' => $this->source,
42
            'deploymentBefore' => $this->deploymentBefore,
43
            'deploymentAfter' => $this->deploymentAfter,
44
            'isTenantIdSet' => $this->isTenantIdSet,
45
            'tenantIds' => $this->tenantIds,
46
            'includeDeploymentsWithoutTenantId' => $this->includeDeploymentsWithoutTenantId
47
        ]);
48
    }
49
50
    public function unserialize($data)
51
    {
52
        $json = json_decode($data);
53
        $this->deploymentId = $json->deploymentId;
54
        $this->name = $json->name;
55
        $this->nameLike = $json->nameLike;
56
        $this->sourceQueryParamEnabled = $json->sourceQueryParamEnabled;
57
        $this->source = $json->source;
58
        $this->deploymentBefore = $json->deploymentBefore;
59
        $this->deploymentAfter = $json->deploymentAfter;
60
        $this->isTenantIdSet = $json->isTenantIdSet;
61
        $this->tenantIds = $json->tenantIds;
62
        $this->includeDeploymentsWithoutTenantId = $json->includeDeploymentsWithoutTenantId;
63
    }
64
65
    public function deploymentId(string $deploymentId): DeploymentQueryImpl
66
    {
67
        EnsureUtil::ensureNotNull("Deployment id", "Deployment id", $deploymentId);
68
        $this->deploymentId = $deploymentId;
69
        return $this;
70
    }
71
72
    public function deploymentName(string $deploymentName): DeploymentQueryImpl
73
    {
74
        EnsureUtil::ensureNotNull("deploymentName", "deploymentName", $deploymentName);
75
        $this->name = $deploymentName;
76
        return $this;
77
    }
78
79
    public function deploymentNameLike(string $nameLike): DeploymentQueryImpl
80
    {
81
        EnsureUtil::ensureNotNull("deploymentNameLike", "deploymentNameLike", $nameLike);
82
        $this->nameLike = $nameLike;
83
        return $this;
84
    }
85
86
    public function deploymentSource(string $source): DeploymentQueryInterface
87
    {
88
        $this->sourceQueryParamEnabled = true;
89
        $this->source = $source;
90
        return $this;
91
    }
92
93
    public function deploymentBefore(string $before): DeploymentQueryInterface
94
    {
95
        EnsureUtil::ensureNotNull("deploymentBefore", "deploymentBefore", $before);
96
        $this->deploymentBefore = $before;
97
        return $this;
98
    }
99
100
    public function deploymentAfter(string $after): DeploymentQueryInterface
101
    {
102
        EnsureUtil::ensureNotNull("deploymentAfter", "deploymentAfter", $after);
103
        $this->deploymentAfter = $after;
104
        return $this;
105
    }
106
107
    public function tenantIdIn(array $tenantIds): DeploymentQueryInterface
108
    {
109
        EnsureUtil::ensureNotNull("tenantIds", "tenantIds", $tenantIds);
110
        $this->tenantIds = $tenantIds;
111
        $this->isTenantIdSet = true;
112
        return $this;
113
    }
114
115
    public function withoutTenantId(): DeploymentQueryInterface
116
    {
117
        $this->isTenantIdSet = true;
118
        $this->tenantIds = null;
119
        return $this;
120
    }
121
122
    public function includeDeploymentsWithoutTenantId(): DeploymentQueryInterface
123
    {
124
        $this->includeDeploymentsWithoutTenantId  = true;
125
        return $this;
126
    }
127
128
    protected function hasExcludingConditions(): bool
129
    {
130
        return parent::hasExcludingConditions() || CompareUtil::areNotInAscendingOrder($this->deploymentAfter, $this->deploymentBefore);
131
    }
132
133
    //sorting ////////////////////////////////////////////////////////
134
135
    public function orderByDeploymentId(): DeploymentQueryInterface
136
    {
137
        return $this->orderBy(DeploymentQueryProperty::deploymentId());
0 ignored issues
show
Bug Best Practice introduced by
The method Jabe\Engine\Impl\Deploym...roperty::deploymentId() is not static, but was called statically. ( Ignorable by Annotation )

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

137
        return $this->orderBy(DeploymentQueryProperty::/** @scrutinizer ignore-call */ deploymentId());
Loading history...
138
    }
139
140
    public function orderByDeploymenTime(): DeploymentQueryInterface
141
    {
142
        return $this->orderBy(DeploymentQueryProperty::deployTime());
0 ignored issues
show
Bug Best Practice introduced by
The method Jabe\Engine\Impl\Deploym...yProperty::deployTime() is not static, but was called statically. ( Ignorable by Annotation )

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

142
        return $this->orderBy(DeploymentQueryProperty::/** @scrutinizer ignore-call */ deployTime());
Loading history...
143
    }
144
145
    public function orderByDeploymentTime(): DeploymentQueryInterface
146
    {
147
        return $this->orderBy(DeploymentQueryProperty::deployTime());
0 ignored issues
show
Bug Best Practice introduced by
The method Jabe\Engine\Impl\Deploym...yProperty::deployTime() is not static, but was called statically. ( Ignorable by Annotation )

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

147
        return $this->orderBy(DeploymentQueryProperty::/** @scrutinizer ignore-call */ deployTime());
Loading history...
148
    }
149
150
    public function orderByDeploymentName(): DeploymentQueryInterface
151
    {
152
        return $this->orderBy(DeploymentQueryProperty::deploymentName());
0 ignored issues
show
Bug Best Practice introduced by
The method Jabe\Engine\Impl\Deploym...perty::deploymentName() is not static, but was called statically. ( Ignorable by Annotation )

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

152
        return $this->orderBy(DeploymentQueryProperty::/** @scrutinizer ignore-call */ deploymentName());
Loading history...
153
    }
154
155
    public function orderByTenantId(): DeploymentQueryInterface
156
    {
157
        return $this->orderBy(DeploymentQueryProperty::tenantId());
0 ignored issues
show
Bug Best Practice introduced by
The method Jabe\Engine\Impl\Deploym...eryProperty::tenantId() is not static, but was called statically. ( Ignorable by Annotation )

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

157
        return $this->orderBy(DeploymentQueryProperty::/** @scrutinizer ignore-call */ tenantId());
Loading history...
158
    }
159
160
    //results ////////////////////////////////////////////////////////
161
162
    public function executeCount(CommandContext $commandContext): int
163
    {
164
        $this->checkQueryOk();
165
        return $commandContext
166
            ->getDeploymentManager()
167
            ->findDeploymentCountByQueryCriteria($this);
168
    }
169
170
    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...
171
    {
172
        $this->checkQueryOk();
173
        return $commandContext
174
            ->getDeploymentManager()
175
            ->findDeploymentsByQueryCriteria($this, $page);
176
    }
177
178
    //getters ////////////////////////////////////////////////////////
179
180
    public function getDeploymentId(): string
181
    {
182
        return $this->deploymentId;
183
    }
184
185
    public function getName(): string
186
    {
187
        return $this->name;
188
    }
189
190
    public function getNameLike(): string
191
    {
192
        return $this->nameLike;
193
    }
194
195
    public function isSourceQueryParamEnabled(): bool
196
    {
197
        return $this->sourceQueryParamEnabled;
198
    }
199
200
    public function getSource(): string
201
    {
202
        return $this->source;
203
    }
204
205
    public function getDeploymentBefore(): string
206
    {
207
        return $this->deploymentBefore;
208
    }
209
210
    public function getDeploymentAfter(): string
211
    {
212
        return $this->deploymentAfter;
213
    }
214
}
215