Completed
Pull Request — master (#24)
by Sergey
10:50 queued 04:42
created

GuzzleHttpClient::setBaseUrl()   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
namespace seregazhuk\SmsIntel\Api;
4
5
use GuzzleHttp\ClientInterface;
6
7
class GuzzleHttpClient
8
{
9
    /**
10
     * @var ClientInterface
11
     */
12
    protected $client;
13
14
    /**
15
     * @param ClientInterface $client
16
     */
17
    public function __construct(ClientInterface $client)
18
    {
19
        $this->client = $client;
20
    }
21
22
    /**
23
     * @param string $uri
24
     * @param array $params
25
     * @return string
26
     */
27
    public function get($uri, $params = [])
28
    {
29
        if (!empty($params)) {
30
            $uri .= '?' . http_build_query($params);
31
        }
32
33
        return (string)$this->client->get($uri)->getBody();
34
    }
35
36
    /**
37
     * @param string $uri
38
     * @param array $body
39
     * @return string
40
     */
41
    public function post($uri, $body = [])
42
    {
43
        return $this->client->post($uri, $body)->getBody();
44
    }
45
}
46