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

Base   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

3 Methods

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