Completed
Push — master ( 390b51...0e9cfd )
by Mario
11:43
created

SymfonyHttpClient::get()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
c 0
b 0
f 0
rs 9.9666
cc 1
nc 1
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Marek\OpenWeatherMap\Http\Client;
6
7
use Marek\OpenWeatherMap\Http\Response\JsonResponse;
8
use Marek\OpenWeatherMap\Http\Response\ResponseInterface;
9
use Symfony\Contracts\HttpClient\HttpClientInterface as BaseHttpClientInterface;
10
11
final class SymfonyHttpClient implements HttpClientInterface
12
{
13
    /**
14
     * @var BaseHttpClientInterface
15
     */
16
    protected $innerClient;
17
18
    public function __construct(BaseHttpClientInterface $innerClient)
19
    {
20
        $this->innerClient = $innerClient;
21
    }
22
23
    public function get(string $url): ResponseInterface
24
    {
25
        $response = $this->innerClient->request('GET', $url);
26
27
28
        return new JsonResponse(
29
            $response->getContent(), $response->getStatusCode()
30
        );
31
    }
32
}
33