Total Complexity | 4 |
Total Lines | 48 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
8 | class Client implements ClientInterface |
||
9 | { |
||
10 | private const URL = 'https://worldcup.sfg.io/'; |
||
11 | private const GAMES = '/matches/today'; |
||
12 | |||
13 | /** |
||
14 | * @var GuzzleHttpClient |
||
15 | */ |
||
16 | private $client; |
||
17 | |||
18 | /** |
||
19 | * @var ParserInterface |
||
20 | */ |
||
21 | private $parser; |
||
22 | |||
23 | /** |
||
24 | * @param ParserInterface $parser |
||
25 | */ |
||
26 | public function __construct(ParserInterface $parser) |
||
27 | { |
||
28 | $this->parser = $parser; |
||
29 | } |
||
30 | |||
31 | /** |
||
32 | * @return \App\GameApi\Persistence\DataProvider\GameResult[] |
||
33 | */ |
||
34 | public function getGames() : array |
||
35 | { |
||
36 | $res = $this->getClient()->get(self::GAMES, $this->options); |
||
|
|||
37 | $gameInfo = (array)json_decode( |
||
38 | (string)$res->getBody()->getContents(), |
||
39 | true |
||
40 | ); |
||
41 | |||
42 | return $this->parser->get($gameInfo); |
||
43 | } |
||
44 | |||
45 | /** |
||
46 | * @return GuzzleHttpClient |
||
47 | */ |
||
48 | private function getClient() : GuzzleHttpClient |
||
56 | } |
||
57 | } |