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

Request   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 2
Bugs 1 Features 0
Metric Value
wmc 2
c 2
b 1
f 0
lcom 1
cbo 2
dl 0
loc 27
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A makeRequest() 0 15 1
A getResponse() 0 4 1
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