Conditions | 3 |
Paths | 3 |
Total Lines | 20 |
Code Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
27 | public function __invoke(): array |
||
28 | { |
||
29 | $channels = $this->channelRepository->findAll(); |
||
30 | |||
31 | $streams = []; |
||
32 | foreach ($channels as $channel) { |
||
33 | $response = $this->twitchItemDataProvider->getStream($channel->getUsername()); |
||
34 | $data = json_decode($response->getBody()->getContents())->data; |
||
35 | if (count($data) === 0) { |
||
36 | continue; |
||
37 | } |
||
38 | |||
39 | $stream = $data[0]; |
||
40 | $serializer = SerializerRegistry::getSerializer(); |
||
41 | $serialized = $serializer->serialize($stream, 'json'); |
||
42 | $deserialized = $serializer->deserialize($serialized, Stream::class, 'json'); |
||
43 | $streams[] = $deserialized; |
||
44 | } |
||
45 | |||
46 | return $streams; |
||
47 | } |
||
49 |