1 | <?php |
||
2 | |||
3 | namespace ZpgRtf\Objects; |
||
4 | |||
5 | /** |
||
6 | * The description is expressed as an array of description objects, each of which represent a paragraph or section. |
||
7 | */ |
||
8 | View Code Duplication | class DescriptionObject implements \JsonSerializable |
|
0 ignored issues
–
show
|
|||
9 | { |
||
10 | /** @var null|string */ |
||
11 | private $heading; |
||
12 | |||
13 | /** @var null|DimensionsObject */ |
||
14 | private $dimensions; |
||
15 | |||
16 | /** @var null|string */ |
||
17 | private $text; |
||
18 | |||
19 | /** |
||
20 | * @return null|string |
||
21 | */ |
||
22 | 3 | public function getHeading() |
|
23 | { |
||
24 | 3 | return $this->heading; |
|
25 | } |
||
26 | |||
27 | /** |
||
28 | * @param string $heading |
||
29 | * |
||
30 | * @return DescriptionObject |
||
31 | */ |
||
32 | 1 | public function setHeading(string $heading): self |
|
33 | { |
||
34 | 1 | $this->heading = $heading; |
|
35 | |||
36 | 1 | return $this; |
|
37 | } |
||
38 | |||
39 | /** |
||
40 | * @return null|DimensionsObject |
||
41 | */ |
||
42 | 3 | public function getDimensions() |
|
43 | { |
||
44 | 3 | return $this->dimensions; |
|
45 | } |
||
46 | |||
47 | /** |
||
48 | * @param DimensionsObject $dimensions |
||
49 | * |
||
50 | * @return DescriptionObject |
||
51 | */ |
||
52 | 1 | public function setDimensions(DimensionsObject $dimensions): self |
|
53 | { |
||
54 | 1 | $this->dimensions = $dimensions; |
|
55 | |||
56 | 1 | return $this; |
|
57 | } |
||
58 | |||
59 | /** |
||
60 | * @return null|string |
||
61 | */ |
||
62 | 3 | public function getText() |
|
63 | { |
||
64 | 3 | return $this->text; |
|
65 | } |
||
66 | |||
67 | /** |
||
68 | * @param string $text |
||
69 | * |
||
70 | * @return DescriptionObject |
||
71 | */ |
||
72 | 2 | public function setText(string $text): self |
|
73 | { |
||
74 | 2 | $this->text = $text; |
|
75 | |||
76 | 2 | return $this; |
|
77 | } |
||
78 | |||
79 | /** {@inheritDoc} */ |
||
80 | 2 | public function jsonSerialize(): array |
|
81 | { |
||
82 | 2 | return array_filter([ |
|
83 | 2 | 'heading' => $this->getHeading(), |
|
84 | 2 | 'dimensions' => $this->getDimensions(), |
|
85 | 2 | 'text' => $this->getText(), |
|
86 | ]); |
||
87 | } |
||
88 | } |
||
89 |
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.