| Conditions | 2 |
| Paths | 2 |
| Total Lines | 14 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 26 | public function __invoke(Channel $channel): JsonResponse |
||
| 27 | { |
||
| 28 | $response = $this->twitchItemDataProvider->getStream($channel->getUsername()); |
||
| 29 | $data = json_decode($response->getBody()->getContents())->data; |
||
| 30 | if (count($data) === 0) { |
||
| 31 | return new JsonResponse(new Stream()); |
||
| 32 | } |
||
| 33 | |||
| 34 | $stream = $data[0]; |
||
| 35 | $serializer = SerializerRegistry::getSerializer(); |
||
| 36 | $serialized = $serializer->serialize($stream, 'json'); |
||
| 37 | $deserialized = $serializer->deserialize($serialized, Stream::class, 'json'); |
||
| 38 | |||
| 39 | return new JsonResponse($deserialized); |
||
| 40 | } |
||
| 42 |