Completed
Push — master ( 55f844...461c20 )
by Chris
01:52
created

Request::makeRequest()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 15
rs 9.4285
cc 1
eloc 9
nc 1
nop 2
1
<?php
2
/**
3
 * @author Chris Hilsdon <[email protected]>
4
 */
5
namespace Cloudflare\Traits;
6
7
use GuzzleHttp\Client;
8
9
trait Request
10
{
11
    protected $request;
12
    protected $response;
13
    public $CF;
14
15
    public function makeRequest($request = "", $type = "GET")
16
    {
17
        $client = new Client();
18
        $this->request = $client->request($type, $this->CF->Endpoint . $request, [
19
            'headers' => [
20
                'X-Auth-Key' => $this->CF->APIKEY,
21
                'X-Auth-Email' => $this->CF->Email
22
            ]
23
        ]);
24
25
        $response = (string) $this->request->getBody();
26
        $this->response = @json_decode($response);
27
28
        return $this;
29
    }
30
31
    public function getResponse()
32
    {
33
        return $this->response;
34
    }
35
}
36