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

SymfonyHttpClient   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 3
dl 0
loc 22
c 0
b 0
f 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A get() 0 9 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