DimensionsObject::setUnits()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 5
ccs 3
cts 3
cp 1
crap 1
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace ZpgRtf\Objects;
4
5
/**
6
 * Information about the dimensions of a room.
7
 */
8
class DimensionsObject implements \JsonSerializable
9
{
10
    /** @var null|float */
11
    private $length;
12
13
    /** @var null|float */
14
    private $width;
15
16
    /**
17
     * Enum (feet, metres)
18
     *
19
     * @var null|string
20
     */
21
    private $units;
22
23
    /**
24
     * @return null|float
25
     */
26 2
    public function getLength()
27
    {
28 2
        return $this->length;
29
    }
30
31
    /**
32
     * @param float $length
33
     *
34
     * @return DimensionsObject
35
     */
36 1
    public function setLength(float $length): self
37
    {
38 1
        $this->length = $length;
39
40 1
        return $this;
41
    }
42
43
    /**
44
     * @return null|float
45
     */
46 2
    public function getWidth()
47
    {
48 2
        return $this->width;
49
    }
50
51
    /**
52
     * @param float $width
53
     *
54
     * @return DimensionsObject
55
     */
56 1
    public function setWidth(float $width): self
57
    {
58 1
        $this->width = $width;
59
60 1
        return $this;
61
    }
62
63
    /**
64
     * @return null|string
65
     */
66 2
    public function getUnits()
67
    {
68 2
        return $this->units;
69
    }
70
71
    /**
72
     * @param string $units
73
     *
74
     * @return DimensionsObject
75
     */
76 1
    public function setUnits(string $units): self
77
    {
78 1
        $this->units = $units;
79
80 1
        return $this;
81
    }
82
83
    /** {@inheritDoc} */
84 1
    public function jsonSerialize(): array
85
    {
86 1
        return array_filter([
87 1
            'length' => $this->getLength(),
88 1
            'width' => $this->getWidth(),
89 1
            'units' => $this->getUnits(),
90
        ]);
91
    }
92
}
93