GuzzleClient   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getUrlData() 0 4 1
1
<?php
2
3
namespace KaLLoSz\Twig\Extension\Client;
4
5
use GuzzleHttp\ClientInterface;
6
use KaLLoSz\Twig\Extension\IframelyClientInterface;
7
use Psr\Http\Message\ResponseInterface;
8
9
class GuzzleClient implements IframelyClientInterface
10
{
11
    /**
12
     * @var null|string
13
     */
14
    private $apiKey;
15
16
    /**
17
     * @var ClientInterface
18
     */
19
    private $client;
20
21
    /**
22
     * Class constructor.
23
     *
24
     * @param string|null $apiKey API key.
25
     * @param ClientInterface $client Guzzle Client
26
     */
27
    public function __construct(string $apiKey, ClientInterface $client)
28
    {
29
        $this->apiKey = $apiKey;
30
        $this->client = $client;
31
    }
32
33
    /**
34
     * {@inheritdoc}
35
     */
36
    public function getUrlData(string $url): ResponseInterface
37
    {
38
        return $this->client->request('GET', '', ['query' => ['api_key' => $this->apiKey, 'url' => $url]]);
39
    }
40
}
41