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

Query::fetchContentAsArray()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 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
}