Passed
Push — develop ( 5b9941...3aaa0d )
by BENARD
08:32
created

GetStream::__invoke()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 2
c 1
b 0
f 1
nc 1
nop 1
dl 0
loc 4
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace ProjetNormandie\TwitchBundle\Controller;
6
7
use GuzzleHttp\Exception\GuzzleException;
8
use ProjetNormandie\TwitchBundle\DataProvider\TwitchItemDataProvider;
9
use ProjetNormandie\TwitchBundle\Entity\Twitch;
10
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
11
use Symfony\Component\HttpFoundation\JsonResponse;
12
13
class GetStream extends AbstractController
14
{
15
    public function __construct(
16
        private readonly TwitchItemDataProvider $twitchItemDataProvider
17
    ) {
18
    }
19
20
21
    /**
22
     * @param Twitch $twitch
23
     * @return JsonResponse
24
     * @throws GuzzleException
25
     */
26
    public function __invoke(Twitch $twitch): JsonResponse
27
    {
28
        $response = $this->twitchItemDataProvider->getStream($twitch->getChannel());
29
        return json_decode($response->getBody()->getContents());
30
    }
31
}
32