Completed
Push — master ( 461d73...ff82ae )
by Paweł
02:26
created

Query   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
dl 0
loc 20
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A fetchContentAsArray() 0 6 1
1
<?php
2
/**
3
 * Created for IG Client.
4
 * User: jakim <[email protected]>
5
 * Date: 16.03.2018
6
 */
7
8
namespace Jakim\Base;
9
10
11
use Jakim\Helper\JsonHelper;
12
13
abstract class Query
14
{
15
    /**
16
     * Psr7 compatible client.
17
     *
18
     * @var \GuzzleHttp\Client
19
     */
20
    protected $httpClient;
21
22
    public function __construct($httpClient)
23
    {
24
        $this->httpClient = $httpClient;
25
    }
26
27
    protected function fetchContentAsArray(string $url): ?array
28
    {
29
        $res = $this->httpClient->get($url);
30
        $content = $res->getBody()->getContents();
31
32
        return JsonHelper::decode($content);
33
    }
34
}