@@ 16-39 (lines=24) @@ | ||
13 | /** |
|
14 | * {@inheritdoc} |
|
15 | */ |
|
16 | public function getEvents($parameters = [], $fetch = self::FETCH_OBJECT) |
|
17 | { |
|
18 | $response = parent::getEvents($parameters, self::FETCH_RESPONSE); |
|
19 | ||
20 | if (200 === $response->getStatusCode()) { |
|
21 | if (self::FETCH_STREAM === $fetch) { |
|
22 | return new EventStream($response->getBody(), $this->serializer); |
|
23 | } |
|
24 | ||
25 | if (self::FETCH_OBJECT === $fetch) { |
|
26 | $eventList = []; |
|
27 | ||
28 | $stream = new EventStream($response->getBody(), $this->serializer); |
|
29 | $stream->onFrame(function (Event $event) use (&$eventList) { |
|
30 | $eventList[] = $event; |
|
31 | }); |
|
32 | $stream->wait(); |
|
33 | ||
34 | return $eventList; |
|
35 | } |
|
36 | } |
|
37 | ||
38 | return $response; |
|
39 | } |
|
40 | } |
|
41 |
@@ 97-120 (lines=24) @@ | ||
94 | * |
|
95 | * @return \Psr\Http\Message\ResponseInterface|CreateImageInfo[]|CreateImageStream |
|
96 | */ |
|
97 | public function create($parameters = [], $fetch = self::FETCH_OBJECT) |
|
98 | { |
|
99 | $response = parent::create($parameters, self::FETCH_RESPONSE); |
|
100 | ||
101 | if (200 === $response->getStatusCode()) { |
|
102 | if (self::FETCH_STREAM === $fetch) { |
|
103 | return new CreateImageStream($response->getBody(), $this->serializer); |
|
104 | } |
|
105 | ||
106 | if (self::FETCH_OBJECT === $fetch) { |
|
107 | $createImageInfoList = []; |
|
108 | ||
109 | $stream = new CreateImageStream($response->getBody(), $this->serializer); |
|
110 | $stream->onFrame(function (CreateImageInfo $createImageInfo) use (&$createImageInfoList) { |
|
111 | $createImageInfoList[] = $createImageInfo; |
|
112 | }); |
|
113 | $stream->wait(); |
|
114 | ||
115 | return $createImageInfoList; |
|
116 | } |
|
117 | } |
|
118 | ||
119 | return $response; |
|
120 | } |
|
121 | ||
122 | /** |
|
123 | * {@inheritdoc} |