Completed
Push — master ( 66d463...29db82 )
by Chris
05:36 queued 01:38
created

Base::__toArray()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
namespace Cloudflare;
3
4
use GuzzleHttp\Client;
5
6
class Base
7
{
8
    public $request;
9
10
    protected function __construct($Cloudflare)
11
    {
12
        $this->CF = $Cloudflare;
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...
13
    }
14
15
    public function makeRequest($request = "", $type = "GET")
16
    {
17
        $client = new Client();
18
        $_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
        $this->response = $this->__toArray((string) $_request->getBody());
0 ignored issues
show
Bug introduced by
The property response 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...
26
27
        return $this->response;
28
    }
29
30
    public function __toArray($data)
31
    {
32
        return @json_decode($data);
33
    }
34
}
35