Completed
Push — develop ( e081a1...30c51d )
by Chris
02:10
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
14
    public function makeRequest($request = "", $type = "GET")
15
    {
16
        $client = new Client();
17
        $this->request = $client->request($type, $this->CF->Endpoint . $request, [
0 ignored issues
show
Bug introduced by
The property CF does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
18
            'headers' => [
19
                'X-Auth-Key' => $this->CF->APIKEY,
20
                'X-Auth-Email' => $this->CF->Email
21
            ]
22
        ]);
23
24
        $response = (string) $this->request->getBody();
25
        $this->response = @json_decode($response);
26
27
        return $this;
28
    }
29
30
    public function getResponse()
31
    {
32
        return $this->response;
33
    }
34
}
35