Zone::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
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