1 | <?php |
||
2 | |||
3 | namespace ZpgRtf\Objects; |
||
4 | |||
5 | /** |
||
6 | * The min_max_area object defines an area range. Where only one is specified, we will regard them both as having the |
||
7 | * same value - i.e. a fixed area. |
||
8 | */ |
||
9 | View Code Duplication | class MinMaxAreaObject implements \JsonSerializable |
|
0 ignored issues
–
show
|
|||
10 | { |
||
11 | /** @var null|AreaObject */ |
||
12 | private $minimum; |
||
13 | |||
14 | /** @var null|AreaObject */ |
||
15 | private $maximum; |
||
16 | |||
17 | /** |
||
18 | * @return null|AreaObject |
||
19 | */ |
||
20 | 2 | public function getMinimum() |
|
21 | { |
||
22 | 2 | return $this->minimum; |
|
23 | } |
||
24 | |||
25 | /** |
||
26 | * @param AreaObject $minimum |
||
27 | * |
||
28 | * @return MinMaxAreaObject |
||
29 | */ |
||
30 | 1 | public function setMinimum(AreaObject $minimum): self |
|
31 | { |
||
32 | 1 | $this->minimum = $minimum; |
|
33 | |||
34 | 1 | return $this; |
|
35 | } |
||
36 | |||
37 | /** |
||
38 | * @return null|AreaObject |
||
39 | */ |
||
40 | 2 | public function getMaximum() |
|
41 | { |
||
42 | 2 | return $this->maximum; |
|
43 | } |
||
44 | |||
45 | /** |
||
46 | * @param AreaObject $maximum |
||
47 | * |
||
48 | * @return MinMaxAreaObject |
||
49 | */ |
||
50 | 1 | public function setMaximum(AreaObject $maximum): self |
|
51 | { |
||
52 | 1 | $this->maximum = $maximum; |
|
53 | |||
54 | 1 | return $this; |
|
55 | } |
||
56 | |||
57 | /** {@inheritDoc} */ |
||
58 | 1 | public function jsonSerialize(): array |
|
59 | { |
||
60 | 1 | return array_filter([ |
|
61 | 1 | 'minimum' => $this->getMinimum(), |
|
62 | 1 | 'maximum' => $this->getMaximum(), |
|
63 | ]); |
||
64 | } |
||
65 | } |
||
66 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.