• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

prooph / event-store-client / 9555551525

17 Jun 2024 10:16PM UTC coverage: 70.262% (-1.1%) from 71.395%
9555551525

push

github

prolic
update coveralls repo token

3466 of 4933 relevant lines covered (70.26%)

67.7 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

76.71
/src/Projections/ProjectionsManager.php
1
<?php
2

3
/**
4
 * This file is part of `prooph/event-store-client`.
5
 * (c) 2018-2024 Alexander Miertsch <kontakt@codeliner.ws>
6
 * (c) 2018-2024 Sascha-Oliver Prolic <saschaprolic@googlemail.com>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11

12
declare(strict_types=1);
13

14
namespace Prooph\EventStoreClient\Projections;
15

16
use Prooph\EventStore\EndPoint;
17
use Prooph\EventStore\Exception\InvalidArgumentException;
18
use Prooph\EventStore\Projections\ProjectionDetails;
19
use Prooph\EventStore\Projections\ProjectionsManager as ProjectionsManagerInterface;
20
use Prooph\EventStore\Projections\ProjectionStatistics;
21
use Prooph\EventStore\Projections\Query;
22
use Prooph\EventStore\Projections\State;
23
use Prooph\EventStore\UserCredentials;
24

25
class ProjectionsManager implements ProjectionsManagerInterface
26
{
27
    private readonly ProjectionsClient $client;
28

29
    public function __construct(
30
        private readonly EndPoint $httpEndPoint,
31
        int $operationTimeout,
32
        bool $tlsTerminatedEndpoint = false,
33
        bool $verifyPeer = true,
34
        private readonly ?UserCredentials $defaultUserCredentials = null
35
    ) {
36
        $this->client = new ProjectionsClient($operationTimeout, $tlsTerminatedEndpoint, $verifyPeer);
20✔
37
    }
38

39
    public function enable(string $name, ?UserCredentials $userCredentials = null): void
40
    {
41
        if ('' === $name) {
1✔
42
            throw new InvalidArgumentException('Name is required');
×
43
        }
44

45
        $this->client->enable(
1✔
46
            $this->httpEndPoint,
1✔
47
            $name,
1✔
48
            $userCredentials ?? $this->defaultUserCredentials
1✔
49
        );
1✔
50
    }
51

52
    public function disable(string $name, ?UserCredentials $userCredentials = null): void
53
    {
54
        if ('' === $name) {
2✔
55
            throw new InvalidArgumentException('Name is required');
×
56
        }
57

58
        $this->client->disable(
2✔
59
            $this->httpEndPoint,
2✔
60
            $name,
2✔
61
            $userCredentials ?? $this->defaultUserCredentials
2✔
62
        );
2✔
63
    }
64

65
    public function abort(string $name, ?UserCredentials $userCredentials = null): void
66
    {
67
        if ('' === $name) {
×
68
            throw new InvalidArgumentException('Name is required');
×
69
        }
70

71
        $this->client->abort(
×
72
            $this->httpEndPoint,
×
73
            $name,
×
74
            $userCredentials ?? $this->defaultUserCredentials
×
75
        );
×
76
    }
77

78
    public function createOneTime(
79
        string $query,
80
        string $type = 'JS',
81
        ?UserCredentials $userCredentials = null
82
    ): void {
83
        if ('' === $query) {
2✔
84
            throw new InvalidArgumentException('Query is required');
×
85
        }
86

87
        $this->client->createOneTime(
2✔
88
            $this->httpEndPoint,
2✔
89
            $query,
2✔
90
            $type,
2✔
91
            $userCredentials ?? $this->defaultUserCredentials
2✔
92
        );
2✔
93
    }
94

95
    public function createTransient(
96
        string $name,
97
        string $query,
98
        string $type = 'JS',
99
        ?UserCredentials $userCredentials = null
100
    ): void {
101
        if ('' === $name) {
1✔
102
            throw new InvalidArgumentException('Name is required');
×
103
        }
104

105
        if ('' === $query) {
1✔
106
            throw new InvalidArgumentException('Query is required');
×
107
        }
108

109
        $this->client->createTransient(
1✔
110
            $this->httpEndPoint,
1✔
111
            $name,
1✔
112
            $query,
1✔
113
            $type,
1✔
114
            $userCredentials ?? $this->defaultUserCredentials
1✔
115
        );
1✔
116
    }
117

118
    public function createContinuous(
119
        string $name,
120
        string $query,
121
        bool $trackEmittedStreams = false,
122
        string $type = 'JS',
123
        ?UserCredentials $userCredentials = null
124
    ): void {
125
        if ('' === $name) {
16✔
126
            throw new InvalidArgumentException('Name is required');
×
127
        }
128

129
        if ('' === $query) {
16✔
130
            throw new InvalidArgumentException('Query is required');
×
131
        }
132

133
        $this->client->createContinuous(
16✔
134
            $this->httpEndPoint,
16✔
135
            $name,
16✔
136
            $query,
16✔
137
            $trackEmittedStreams,
16✔
138
            $type,
16✔
139
            $userCredentials ?? $this->defaultUserCredentials
16✔
140
        );
16✔
141
    }
142

143
    /** @inheritDoc */
144
    public function listAll(?UserCredentials $userCredentials = null): array
145
    {
146
        return $this->client->listAll(
1✔
147
            $this->httpEndPoint,
1✔
148
            $userCredentials ?? $this->defaultUserCredentials
1✔
149
        );
1✔
150
    }
151

152
    /** @inheritdoc */
153
    public function listOneTime(?UserCredentials $userCredentials = null): array
154
    {
155
        return $this->client->listOneTime(
2✔
156
            $this->httpEndPoint,
2✔
157
            $userCredentials ?? $this->defaultUserCredentials
2✔
158
        );
2✔
159
    }
160

161
    /** @inheritdoc */
162
    public function listContinuous(?UserCredentials $userCredentials = null): array
163
    {
164
        return $this->client->listContinuous(
3✔
165
            $this->httpEndPoint,
3✔
166
            $userCredentials ?? $this->defaultUserCredentials
3✔
167
        );
3✔
168
    }
169

170
    /** @inheritdoc */
171
    public function getStatus(string $name, ?UserCredentials $userCredentials = null): ProjectionDetails
172
    {
173
        if ('' === $name) {
5✔
174
            throw new InvalidArgumentException('Name is required');
×
175
        }
176

177
        return $this->client->getStatus(
5✔
178
            $this->httpEndPoint,
5✔
179
            $name,
5✔
180
            $userCredentials ?? $this->defaultUserCredentials
5✔
181
        );
5✔
182
    }
183

184
    /** @inheritdoc */
185
    public function getState(string $name, ?UserCredentials $userCredentials = null): State
186
    {
187
        if ('' === $name) {
1✔
188
            throw new InvalidArgumentException('Name is required');
×
189
        }
190

191
        return $this->client->getState(
1✔
192
            $this->httpEndPoint,
1✔
193
            $name,
1✔
194
            $userCredentials ?? $this->defaultUserCredentials
1✔
195
        );
1✔
196
    }
197

198
    /** @inheritdoc */
199
    public function getPartitionState(
200
        string $name,
201
        string $partition,
202
        ?UserCredentials $userCredentials = null
203
    ): State {
204
        if ('' === $name) {
1✔
205
            throw new InvalidArgumentException('Name is required');
×
206
        }
207

208
        if ('' === $partition) {
1✔
209
            throw new InvalidArgumentException('Partition is required');
×
210
        }
211

212
        return $this->client->getPartitionState(
1✔
213
            $this->httpEndPoint,
1✔
214
            $name,
1✔
215
            $partition,
1✔
216
            $userCredentials ?? $this->defaultUserCredentials
1✔
217
        );
1✔
218
    }
219

220
    /** @inheritdoc */
221
    public function getResult(string $name, ?UserCredentials $userCredentials = null): State
222
    {
223
        if ('' === $name) {
1✔
224
            throw new InvalidArgumentException('Name is required');
×
225
        }
226

227
        return $this->client->getResult(
1✔
228
            $this->httpEndPoint,
1✔
229
            $name,
1✔
230
            $userCredentials ?? $this->defaultUserCredentials
1✔
231
        );
1✔
232
    }
233

234
    /** @inheritdoc */
235
    public function getPartitionResult(
236
        string $name,
237
        string $partition,
238
        ?UserCredentials $userCredentials = null
239
    ): State {
240
        if ('' === $name) {
1✔
241
            throw new InvalidArgumentException('Name is required');
×
242
        }
243

244
        if ('' === $partition) {
1✔
245
            throw new InvalidArgumentException('Partition is required');
×
246
        }
247

248
        return $this->client->getPartitionResult(
1✔
249
            $this->httpEndPoint,
1✔
250
            $name,
1✔
251
            $partition,
1✔
252
            $userCredentials ?? $this->defaultUserCredentials
1✔
253
        );
1✔
254
    }
255

256
    /** @inheritdoc */
257
    public function getStatistics(string $name, ?UserCredentials $userCredentials = null): ProjectionStatistics
258
    {
259
        if ('' === $name) {
1✔
260
            throw new InvalidArgumentException('Name is required');
×
261
        }
262

263
        return $this->client->getStatistics(
1✔
264
            $this->httpEndPoint,
1✔
265
            $name,
1✔
266
            $userCredentials ?? $this->defaultUserCredentials
1✔
267
        );
1✔
268
    }
269

270
    /** @inheritdoc */
271
    public function getQuery(string $name, ?UserCredentials $userCredentials = null): Query
272
    {
273
        if ('' === $name) {
2✔
274
            throw new InvalidArgumentException('Name is required');
×
275
        }
276

277
        return $this->client->getQuery(
2✔
278
            $this->httpEndPoint,
2✔
279
            $name,
2✔
280
            $userCredentials ?? $this->defaultUserCredentials
2✔
281
        );
2✔
282
    }
283

284
    public function updateQuery(
285
        string $name,
286
        string $query,
287
        ?bool $emitEnabled = null,
288
        ?UserCredentials $userCredentials = null
289
    ): void {
290
        if ('' === $name) {
1✔
291
            throw new InvalidArgumentException('Name is required');
×
292
        }
293

294
        if ('' === $query) {
1✔
295
            throw new InvalidArgumentException('Query is required');
×
296
        }
297

298
        $this->client->updateQuery(
1✔
299
            $this->httpEndPoint,
1✔
300
            $name,
1✔
301
            $query,
1✔
302
            $emitEnabled,
1✔
303
            $userCredentials ?? $this->defaultUserCredentials
1✔
304
        );
1✔
305
    }
306

307
    public function delete(
308
        string $name,
309
        bool $deleteEmittedStreams = false,
310
        ?UserCredentials $userCredentials = null
311
    ): void {
312
        if ('' === $name) {
×
313
            throw new InvalidArgumentException('Name is required');
×
314
        }
315

316
        $this->client->delete(
×
317
            $this->httpEndPoint,
×
318
            $name,
×
319
            $deleteEmittedStreams,
×
320
            $userCredentials ?? $this->defaultUserCredentials
×
321
        );
×
322
    }
323

324
    public function reset(string $name, ?UserCredentials $userCredentials = null): void
325
    {
326
        if ('' === $name) {
1✔
327
            throw new InvalidArgumentException('Name is required');
×
328
        }
329

330
        $this->client->reset(
1✔
331
            $this->httpEndPoint,
1✔
332
            $name,
1✔
333
            $userCredentials ?? $this->defaultUserCredentials
1✔
334
        );
1✔
335
    }
336
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc