Client::getChannels()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
namespace MauroMoreno\DataFactory;
4
5
use GuzzleHttp\Client as GuzzleClient;
6
7
/**
8
 * Class Client
9
 *
10
 * @package MauroMoreno\DataFactory
11
 */
12
class Client
13
{
14
15
    // URL Datafactory.la
16
    const BASE_URI = 'http://feed.datafactory.la';
17
18
    /**
19
     * @var \GuzzleHttp\Client
20
     */
21
    private $guzzleClient;
22
23
    /**
24
     * Client constructor.
25
     *
26
     * @param array $config
27
     */
28 4
    public function __construct(array $config = [])
29
    {
30 4
        $defaults = ['base_uri' => self::BASE_URI];
31 4
        $config = array_merge($defaults, $config);
32 4
        $this->guzzleClient = new GuzzleClient($config);
33 4
    }
34
35
    /**
36
     * Get Channels
37
     *
38
     * @return \Psr\Http\Message\ResponseInterface
39
     */
40 1
    public function getChannels()
41
    {
42 1
        return $this->getGuzzleClient()->get('/');
43
    }
44
45
    /**
46
     * Get Channel
47
     *
48
     * @param string $channel
49
     *
50
     * @return \Psr\Http\Message\ResponseInterface
51
     */
52 2
    public function getChannel(string $channel)
53
    {
54
        $params = [
55 2
            'canal' => $channel
56
        ];
57 2
        return $this->getGuzzleClient()->get('/', ['query' => $params]);
58
    }
59
60
    /**
61
     * Get Guzzle Client
62
     *
63
     * @return \GuzzleHttp\Client
64
     */
65 4
    public function getGuzzleClient()
66
    {
67 4
        return $this->guzzleClient;
68
    }
69
70
}
71