Zone::get()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 3
c 1
b 0
f 0
nc 2
nop 2
dl 0
loc 7
ccs 4
cts 4
cp 1
crap 2
rs 10
1
<?php
2
3
namespace Sebdesign\ArtisanCloudflare;
4
5
use JsonSerializable;
6
7
class Zone implements JsonSerializable
8
{
9
    /** @var array */
10
    private $parameters;
11
12 69
    public function __construct(array $parameters = [])
13
    {
14 69
        $this->parameters = $parameters;
15 69
    }
16
17 36
    public function replace(array $parameters): void
18
    {
19 36
        $this->parameters = $parameters;
20 36
    }
21
22
    #[\ReturnTypeWillChange]
23 63
    public function jsonSerialize(): array
24
    {
25 63
        if (empty($this->parameters)) {
26 15
            return ['purge_everything' => true];
27
        }
28
29 57
        return $this->parameters;
30
    }
31
32 51
    public function get($key, $default = null)
33
    {
34 51
        if (isset($this->parameters[$key])) {
35 51
            return $this->parameters[$key];
36
        }
37
38 24
        return $default;
39
    }
40
}
41