1 | <?php |
||
30 | final class EventStore implements EventStoreInterface |
||
31 | { |
||
32 | /** |
||
33 | * @var string |
||
34 | */ |
||
35 | private $url; |
||
36 | |||
37 | /** |
||
38 | * @var Client |
||
39 | */ |
||
40 | private $httpClient; |
||
41 | |||
42 | /** |
||
43 | * @var ResponseInterface |
||
44 | */ |
||
45 | private $lastResponse; |
||
46 | |||
47 | /** |
||
48 | * @var array |
||
49 | */ |
||
50 | private $badCodeHandlers = []; |
||
51 | |||
52 | /** |
||
53 | * @param string $url Endpoint of the EventStore HTTP API |
||
54 | * @param HttpClientInterface the http client |
||
55 | */ |
||
56 | 26 | public function __construct($url, HttpClientInterface $httpClient = null) |
|
64 | |||
65 | /** |
||
66 | * Delete a stream |
||
67 | * |
||
68 | * @param string $streamName Name of the stream |
||
69 | * @param StreamDeletion $mode Deletion mode (soft or hard) |
||
70 | */ |
||
71 | 4 | public function deleteStream($streamName, StreamDeletion $mode) |
|
81 | |||
82 | /** |
||
83 | * Get the response from the last HTTP call to the EventStore API |
||
84 | * |
||
85 | * @return ResponseInterface |
||
86 | */ |
||
87 | 23 | public function getLastResponse() |
|
91 | |||
92 | /** |
||
93 | * Navigate stream feed through link relations |
||
94 | * |
||
95 | * @param StreamFeed $streamFeed The stream feed to navigate through |
||
96 | * @param LinkRelation $relation The "direction" expressed as link relation |
||
97 | * @return null|StreamFeed |
||
98 | */ |
||
99 | 8 | public function navigateStreamFeed(StreamFeed $streamFeed, LinkRelation $relation) |
|
109 | |||
110 | /** |
||
111 | * Open a stream feed for read and navigation |
||
112 | * |
||
113 | * @param string $streamName The stream name |
||
114 | * @param EntryEmbedMode $embedMode The event entries embed mode (none, rich or body) |
||
115 | * @return StreamFeed |
||
116 | */ |
||
117 | 18 | public function openStreamFeed($streamName, EntryEmbedMode $embedMode = null) |
|
123 | |||
124 | /** |
||
125 | * Read a single event |
||
126 | * |
||
127 | * @param string $eventUrl The url of the event |
||
128 | * @return Event |
||
129 | */ |
||
130 | 3 | public function readEvent($eventUrl) |
|
141 | |||
142 | /** |
||
143 | * Read a single event |
||
144 | * |
||
145 | * @param string $eventUrl The url of the event |
||
146 | * @return Event |
||
147 | */ |
||
148 | 7 | public function readEventBatch(array $eventUrls) |
|
170 | |||
171 | /** |
||
172 | * @param array $content |
||
173 | * @return Event |
||
174 | */ |
||
175 | 9 | protected function createEventFromResponseContent(array $content) |
|
184 | |||
185 | /** |
||
186 | * Write one or more events to a stream |
||
187 | * |
||
188 | * @param string $streamName The stream name |
||
189 | * @param WritableToStream $events Single event or a collection of events |
||
190 | * @param int $expectedVersion The expected version of the stream |
||
191 | * @throws Exception\WrongExpectedVersionException |
||
192 | */ |
||
193 | 22 | public function writeToStream($streamName, WritableToStream $events, $expectedVersion = ExpectedVersion::ANY) |
|
217 | |||
218 | /** |
||
219 | * @param string $streamName |
||
220 | * @return StreamFeedIterator |
||
221 | */ |
||
222 | 1 | public function forwardStreamFeedIterator($streamName) |
|
226 | |||
227 | /** |
||
228 | * @param string $streamName |
||
229 | * @return StreamFeedIterator |
||
230 | */ |
||
231 | 1 | public function backwardStreamFeedIterator($streamName) |
|
235 | |||
236 | /** |
||
237 | * @throws Exception\ConnectionFailedException |
||
238 | */ |
||
239 | 26 | private function checkConnection() |
|
248 | |||
249 | /** |
||
250 | * @param string $streamName |
||
251 | * @return string |
||
252 | */ |
||
253 | 24 | private function getStreamUrl($streamName) |
|
257 | |||
258 | /** |
||
259 | * @param string $streamUrl |
||
260 | * @param EntryEmbedMode $embedMode |
||
261 | * @return StreamFeed |
||
262 | * @throws Exception\StreamDeletedException |
||
263 | * @throws Exception\StreamNotFoundException |
||
264 | */ |
||
265 | 18 | private function readStreamFeed($streamUrl, EntryEmbedMode $embedMode = null) |
|
285 | |||
286 | /** |
||
287 | * @param string $uri |
||
288 | * @return \GuzzleHttp\Message\Request|RequestInterface |
||
289 | */ |
||
290 | 18 | private function getJsonRequest($uri) |
|
300 | |||
301 | /** |
||
302 | * @param RequestInterface $request |
||
303 | */ |
||
304 | 26 | private function sendRequest(RequestInterface $request) |
|
312 | |||
313 | /** |
||
314 | * @param string $streamUrl |
||
315 | * @throws Exception\StreamDeletedException |
||
316 | * @throws Exception\StreamNotFoundException |
||
317 | * @throws Exception\UnauthorizedException |
||
318 | */ |
||
319 | 18 | private function ensureStatusCodeIsGood($streamUrl) |
|
327 | |||
328 | 26 | private function initBadCodeHandlers() |
|
359 | |||
360 | 15 | private function lastResponseAsJson() |
|
364 | } |
||
365 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..