ServiceChargeObject::jsonSerialize()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 0
dl 0
loc 6
ccs 5
cts 5
cp 1
crap 1
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace ZpgRtf\Objects;
4
5
/**
6
 * This object describes any ongoing service charges which are applicable. Note that you can only specify one of
7
 * per_unit_area_units or frequency.
8
 */
9
class ServiceChargeObject implements \JsonSerializable
10
{
11
    /** @var null|float */
12
    private $charge;
13
14
    /**
15
     * Enum (sq_feet, sq_yards, sq_metres, acres, hectares)
16
     *
17
     * @var null|string
18
     */
19
    private $perUnitAreaUnits;
20
21
    /**
22
     * Enum (per_person_per_week, per_week, per_month, per_quarter, per_year)
23
     *
24
     * @var null|string
25
     */
26
    private $frequency;
27
28
    /**
29
     * @return null|float
30
     */
31 2
    public function getCharge()
32
    {
33 2
        return $this->charge;
34
    }
35
36
    /**
37
     * @param float $charge
38
     *
39
     * @return ServiceChargeObject
40
     */
41 1
    public function setCharge(float $charge): self
42
    {
43 1
        $this->charge = $charge;
44
45 1
        return $this;
46
    }
47
48
    /**
49
     * @return null|string
50
     */
51 2
    public function getPerUnitAreaUnits()
52
    {
53 2
        return $this->perUnitAreaUnits;
54
    }
55
56
    /**
57
     * @param string $perUnitAreaUnits
58
     *
59
     * @return ServiceChargeObject
60
     */
61 1
    public function setPerUnitAreaUnits(string $perUnitAreaUnits): self
62
    {
63 1
        $this->perUnitAreaUnits = $perUnitAreaUnits;
64
65 1
        return $this;
66
    }
67
68
    /**
69
     * @return null|string
70
     */
71 2
    public function getFrequency()
72
    {
73 2
        return $this->frequency;
74
    }
75
76
    /**
77
     * @param string $frequency
78
     *
79
     * @return ServiceChargeObject
80
     */
81 1
    public function setFrequency(string $frequency): self
82
    {
83 1
        $this->frequency = $frequency;
84
85 1
        return $this;
86
    }
87
88
    /** {@inheritDoc} */
89 1
    public function jsonSerialize(): array
90
    {
91 1
        return array_filter([
92 1
            'charge' => $this->getCharge(),
93 1
            'per_unit_area_units' => $this->getPerUnitAreaUnits(),
94 1
            'frequency' => $this->getFrequency(),
95
        ]);
96
    }
97
}
98