Completed
Push — master ( 461c20...02a675 )
by Chris
01:56
created

Zone::getAll()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 5
rs 9.4285
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
/*
3
 * @author Chris Hilsdon <[email protected]>
4
 *
5
 * @link https://api.cloudflare.com/#zone
6
 */
7
namespace Cloudflare;
8
9
class Zone extends Base
10
{
11
    protected $URL = "zones";
12
13
    /**
14
     *
15
     * @link https://api.cloudflare.com/#zone-list-zones
16
     */
17
    public function getAll()
18
    {
19
        $this->makeRequest($this->URL);
20
        return $this->getResponse();
21
    }
22
23
    /**
24
     *
25
     * @link https://api.cloudflare.com/#zone-list-zones
26
     */
27
    public function get($name = '', $options = [])
28
    {
29
        $defaultOptions = [
30
            'status' => 'active',
31
            'page' => 1,
32
            'per_page' => 20,
33
            'order' => 'status',
34
            'direction' => 'asc',
35
            'match' => 'all',
36
        ];
37
38
        $newOptions = [
39
            'name' => $name
40
        ];
41
42
        $newOptions = array_merge($newOptions, $defaultOptions, $options);
43
44
        $string = "?";
45
        foreach ($newOptions as $k => $v) {
46
            $string .= $k . '=' . $v . '&';
47
        }
48
49
        //Remove the last '&'
50
        $string = substr($string, 0, -1);
51
52
        $this->makeRequest($this->URL . $string);
53
        return $this->getResponse();
54
    }
55
}
56