Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
Complex classes like PaymentSlip often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use PaymentSlip, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
38 | abstract class PaymentSlip |
||
39 | { |
||
40 | /** |
||
41 | * The payment slip value object, which contains the payment slip data |
||
42 | * |
||
43 | * @var PaymentSlipData |
||
44 | */ |
||
45 | protected $paymentSlipData = null; |
||
46 | |||
47 | /** |
||
48 | * Starting X position of the slip in mm |
||
49 | * |
||
50 | * @var int|float |
||
51 | */ |
||
52 | protected $slipPosX = 0; |
||
53 | |||
54 | /** |
||
55 | * Starting Y position of the slip in mm |
||
56 | * |
||
57 | * @var int|float |
||
58 | */ |
||
59 | protected $slipPosY = 191; |
||
60 | |||
61 | /** |
||
62 | * The height of the slip |
||
63 | * |
||
64 | * @var int|float |
||
65 | */ |
||
66 | protected $slipHeight = 106; // default height of an orange slip |
||
67 | |||
68 | /** |
||
69 | * The width of the slip |
||
70 | * |
||
71 | * @var int|float |
||
72 | */ |
||
73 | protected $slipWidth = 210; // default width of an orange slip |
||
74 | |||
75 | /** |
||
76 | * Background of the slip |
||
77 | * |
||
78 | * Can be either 'transparent', a color or an image |
||
79 | * |
||
80 | * @var null|string |
||
81 | */ |
||
82 | protected $slipBackground = null; |
||
83 | |||
84 | /** |
||
85 | * The default font family |
||
86 | * |
||
87 | * @var string |
||
88 | */ |
||
89 | protected $defaultFontFamily = 'Helvetica'; |
||
90 | |||
91 | /** |
||
92 | * The default font size |
||
93 | * |
||
94 | * @var string |
||
95 | */ |
||
96 | protected $defaultFontSize = '10'; |
||
97 | |||
98 | /** |
||
99 | * The default font color |
||
100 | * |
||
101 | * @var string |
||
102 | */ |
||
103 | protected $defaultFontColor = '#000'; |
||
104 | |||
105 | /** |
||
106 | * The default line height |
||
107 | * |
||
108 | * @var int |
||
109 | */ |
||
110 | protected $defaultLineHeight = 4; |
||
111 | |||
112 | /** |
||
113 | * The default text alignment |
||
114 | * |
||
115 | * @var string |
||
116 | */ |
||
117 | protected $defaultTextAlign = 'L'; |
||
118 | |||
119 | /** |
||
120 | * Determines whether the background should be displayed |
||
121 | * |
||
122 | * @var bool |
||
123 | */ |
||
124 | protected $displayBackground = true; |
||
125 | |||
126 | /** |
||
127 | * Determines whether the bank details should be displayed |
||
128 | * |
||
129 | * @var bool |
||
130 | */ |
||
131 | protected $displayBank = true; |
||
132 | |||
133 | /** |
||
134 | * Determines whether the recipient details should be displayed |
||
135 | * |
||
136 | * @var bool |
||
137 | */ |
||
138 | protected $displayRecipient = true; |
||
139 | |||
140 | /** |
||
141 | * Determines whether the account should be displayed |
||
142 | * |
||
143 | * @var bool |
||
144 | */ |
||
145 | protected $displayAccount = true; |
||
146 | |||
147 | /** |
||
148 | * Determines whether the amount should be displayed |
||
149 | * |
||
150 | * @var bool |
||
151 | */ |
||
152 | protected $displayAmount = true; |
||
153 | |||
154 | /** |
||
155 | * Determines whether the payer details should be displayed |
||
156 | * |
||
157 | * @var bool |
||
158 | */ |
||
159 | protected $displayPayer = true; |
||
160 | |||
161 | /** |
||
162 | * Attributes of the left bank element |
||
163 | * |
||
164 | * @var array |
||
165 | */ |
||
166 | protected $bankLeftAttr = []; |
||
167 | |||
168 | /** |
||
169 | * Attributes of the right bank element |
||
170 | * |
||
171 | * @var array |
||
172 | */ |
||
173 | protected $bankRightAttr = []; |
||
174 | |||
175 | /** |
||
176 | * Attributes of the left recipient element |
||
177 | * |
||
178 | * @var array |
||
179 | */ |
||
180 | protected $recipientLeftAttr = []; |
||
181 | |||
182 | /** |
||
183 | * Attributes of the right recipient element |
||
184 | * |
||
185 | * @var array |
||
186 | */ |
||
187 | protected $recipientRightAttr = []; |
||
188 | |||
189 | /** |
||
190 | * Attributes of the left account element |
||
191 | * |
||
192 | * @var array |
||
193 | */ |
||
194 | protected $accountLeftAttr = []; |
||
195 | |||
196 | /** |
||
197 | * Attributes of the right account element |
||
198 | * |
||
199 | * @var array |
||
200 | */ |
||
201 | protected $accountRightAttr = []; |
||
202 | |||
203 | /** |
||
204 | * Attributes of the left francs amount element |
||
205 | * |
||
206 | * @var array |
||
207 | */ |
||
208 | protected $amountFrancsLeftAttr = []; |
||
209 | |||
210 | /** |
||
211 | * Attributes of the right francs amount element |
||
212 | * |
||
213 | * @var array |
||
214 | */ |
||
215 | protected $amountFrancsRightAttr = []; |
||
216 | |||
217 | /** |
||
218 | * Attributes of the left cents amount element |
||
219 | * |
||
220 | * @var array |
||
221 | */ |
||
222 | protected $amountCentsLeftAttr = []; |
||
223 | |||
224 | /** |
||
225 | * Attributes of the right cents amount element |
||
226 | * |
||
227 | * @var array |
||
228 | */ |
||
229 | protected $amountCentsRightAttr = []; |
||
230 | |||
231 | /** |
||
232 | * Attributes of the left payer element |
||
233 | * |
||
234 | * @var array |
||
235 | */ |
||
236 | protected $payerLeftAttr = []; |
||
237 | |||
238 | /** |
||
239 | * Attributes of the right payer element |
||
240 | * |
||
241 | * @var array |
||
242 | */ |
||
243 | protected $payerRightAttr = []; |
||
244 | |||
245 | /** |
||
246 | * Create a new payment slip |
||
247 | * |
||
248 | * @param PaymentSlipData $paymentSlipData The payment slip data. |
||
249 | * @param float|null $slipPosX The optional X position of the slip. |
||
250 | * @param float|null $slipPosY The optional Y position of the slip. |
||
251 | */ |
||
252 | 1 | public function __construct(PaymentSlipData $paymentSlipData, $slipPosX = null, $slipPosY = null) |
|
265 | |||
266 | /** |
||
267 | * Sets the common default attributes of the elements |
||
268 | * |
||
269 | * @return $this The current instance for a fluent interface. |
||
270 | */ |
||
271 | 13 | protected function setDefaults() |
|
288 | |||
289 | /** |
||
290 | * Get the slip data object of the slip |
||
291 | * |
||
292 | * @return PaymentSlipData The data object of the slip. |
||
293 | */ |
||
294 | 1 | public function getPaymentSlipData() |
|
298 | |||
299 | /** |
||
300 | * Set the starting X & Y position of the slip |
||
301 | * |
||
302 | * @param float $slipPosX The starting X position of the slip. |
||
303 | * @param float $slipPosY The starting Y position of the slip |
||
304 | * @return $this The current instance for a fluent interface. |
||
305 | */ |
||
306 | 3 | public function setSlipPosition($slipPosX, $slipPosY) |
|
313 | |||
314 | /** |
||
315 | * Set the starting X position of the slip |
||
316 | * |
||
317 | * @param float $slipPosX The starting X position of the slip. |
||
318 | * @return $this The current instance for a fluent interface. |
||
319 | */ |
||
320 | 1 | protected function setSlipPosX($slipPosX) |
|
327 | |||
328 | /** |
||
329 | * Set the starting Y position of the slip |
||
330 | * |
||
331 | * @param float $slipPosY The starting Y position of the slip. |
||
332 | * @return $this The current instance for a fluent interface. |
||
333 | */ |
||
334 | 1 | protected function setSlipPosY($slipPosY) |
|
341 | |||
342 | /** |
||
343 | * Set the height & width of the slip |
||
344 | * |
||
345 | * @param float $slipWidth The width of the slip |
||
346 | * @param float $slipHeight The height of the slip |
||
347 | * @return $this The current instance for a fluent interface. |
||
348 | */ |
||
349 | 3 | public function setSlipSize($slipWidth, $slipHeight) |
|
356 | |||
357 | /** |
||
358 | * Set the width of the slip |
||
359 | * |
||
360 | * @param float $slipWidth The width of the slip |
||
361 | * @return $this The current instance for a fluent interface. |
||
362 | */ |
||
363 | 1 | protected function setSlipWidth($slipWidth) |
|
370 | |||
371 | /** |
||
372 | * Set the height of the slip |
||
373 | * |
||
374 | * @param float $slipHeight The height of the slip |
||
375 | * @return $this The current instance for a fluent interface. |
||
376 | */ |
||
377 | 1 | protected function setSlipHeight($slipHeight) |
|
384 | |||
385 | /** |
||
386 | * Set the background of the slip |
||
387 | * |
||
388 | * Can be either 'transparent', a color or an image |
||
389 | * |
||
390 | * @param string $slipBackground The background of the slip. |
||
391 | * @return $this The current instance for a fluent interface. |
||
392 | * |
||
393 | * @todo Implement sanity checks on parameter (filename or color) |
||
394 | */ |
||
395 | 1 | public function setSlipBackground($slipBackground) |
|
401 | |||
402 | /** |
||
403 | * Set the attributes for a given payment slip element |
||
404 | * |
||
405 | * @param array $element The element (attributes) to set. |
||
406 | * @param float|null $posX The X position. |
||
407 | * @param float|null $posY The Y Position. |
||
408 | * @param float|null $width The width. |
||
409 | * @param float|null $height The height. |
||
410 | * @param string|null $background The background. |
||
411 | * @param string|null $fontFamily The font family. |
||
412 | * @param float|null $fontSize The font size. |
||
413 | * @param string|null $fontColor The font color. |
||
414 | * @param float|null $lineHeight The line height. |
||
415 | * @param string|null $textAlign The text alignment. |
||
416 | * @return $this The current instance for a fluent interface. |
||
417 | */ |
||
418 | 15 | protected function setAttributes( |
|
484 | |||
485 | /** |
||
486 | * Set the left bank attributes |
||
487 | * |
||
488 | * @param float|null $posX The X position. |
||
489 | * @param float|null $posY The Y Position. |
||
490 | * @param float|null $width The width. |
||
491 | * @param float|null $height The height. |
||
492 | * @param string|null $background The background. |
||
493 | * @param string|null $fontFamily The font family. |
||
494 | * @param float|null $fontSize The font size. |
||
495 | * @param string|null $fontColor The font color. |
||
496 | * @param float|null $lineHeight The line height. |
||
497 | * @param string|null $textAlign The text alignment. |
||
498 | * @return $this The current instance for a fluent interface. |
||
499 | */ |
||
500 | 1 | View Code Duplication | public function setBankLeftAttr( |
528 | |||
529 | /** |
||
530 | * Set the right bank attributes |
||
531 | * |
||
532 | * @param float|null $posX The X position. |
||
533 | * @param float|null $posY The Y Position. |
||
534 | * @param float|null $width The width. |
||
535 | * @param float|null $height The height. |
||
536 | * @param string|null $background The background. |
||
537 | * @param string|null $fontFamily The font family. |
||
538 | * @param float|null $fontSize The font size. |
||
539 | * @param string|null $fontColor The font color. |
||
540 | * @param float|null $lineHeight The line height. |
||
541 | * @param string|null $textAlign The text alignment. |
||
542 | * @return $this The current instance for a fluent interface. |
||
543 | */ |
||
544 | 1 | View Code Duplication | public function setBankRightAttr( |
572 | |||
573 | /** |
||
574 | * Set the left recipient attributes |
||
575 | * |
||
576 | * @param float|null $posX The X position. |
||
577 | * @param float|null $posY The Y Position. |
||
578 | * @param float|null $width The width. |
||
579 | * @param float|null $height The height. |
||
580 | * @param string|null $background The background. |
||
581 | * @param string|null $fontFamily The font family. |
||
582 | * @param float|null $fontSize The font size. |
||
583 | * @param string|null $fontColor The font color. |
||
584 | * @param float|null $lineHeight The line height. |
||
585 | * @param string|null $textAlign The text alignment. |
||
586 | * @return $this The current instance for a fluent interface. |
||
587 | */ |
||
588 | 1 | View Code Duplication | public function setRecipientLeftAttr( |
616 | |||
617 | /** |
||
618 | * Set the right recipient attributes |
||
619 | * |
||
620 | * @param float|null $posX The X position. |
||
621 | * @param float|null $posY The Y Position. |
||
622 | * @param float|null $width The width. |
||
623 | * @param float|null $height The height. |
||
624 | * @param string|null $background The background. |
||
625 | * @param string|null $fontFamily The font family. |
||
626 | * @param float|null $fontSize The font size. |
||
627 | * @param string|null $fontColor The font color. |
||
628 | * @param float|null $lineHeight The line height. |
||
629 | * @param string|null $textAlign The text alignment. |
||
630 | * @return $this The current instance for a fluent interface. |
||
631 | */ |
||
632 | 1 | View Code Duplication | public function setRecipientRightAttr( |
660 | |||
661 | /** |
||
662 | * Set the left account attributes |
||
663 | * |
||
664 | * @param float|null $posX The X position. |
||
665 | * @param float|null $posY The Y Position. |
||
666 | * @param float|null $width The width. |
||
667 | * @param float|null $height The height. |
||
668 | * @param string|null $background The background. |
||
669 | * @param string|null $fontFamily The font family. |
||
670 | * @param float|null $fontSize The font size. |
||
671 | * @param string|null $fontColor The font color. |
||
672 | * @param float|null $lineHeight The line height. |
||
673 | * @param string|null $textAlign The text alignment. |
||
674 | * @return $this The current instance for a fluent interface. |
||
675 | */ |
||
676 | 1 | View Code Duplication | public function setAccountLeftAttr( |
704 | |||
705 | /** |
||
706 | * Set the right account attributes |
||
707 | * |
||
708 | * @param float|null $posX The X position. |
||
709 | * @param float|null $posY The Y Position. |
||
710 | * @param float|null $width The width. |
||
711 | * @param float|null $height The height. |
||
712 | * @param string|null $background The background. |
||
713 | * @param string|null $fontFamily The font family. |
||
714 | * @param float|null $fontSize The font size. |
||
715 | * @param string|null $fontColor The font color. |
||
716 | * @param float|null $lineHeight The line height. |
||
717 | * @param string|null $textAlign The text alignment. |
||
718 | * @return $this The current instance for a fluent interface. |
||
719 | */ |
||
720 | 1 | View Code Duplication | public function setAccountRightAttr( |
748 | |||
749 | /** |
||
750 | * Set the left francs amount attributes |
||
751 | * |
||
752 | * @param float|null $posX The X position. |
||
753 | * @param float|null $posY The Y Position. |
||
754 | * @param float|null $width The width. |
||
755 | * @param float|null $height The height. |
||
756 | * @param string|null $background The background. |
||
757 | * @param string|null $fontFamily The font family. |
||
758 | * @param float|null $fontSize The font size. |
||
759 | * @param string|null $fontColor The font color. |
||
760 | * @param float|null $lineHeight The line height. |
||
761 | * @param string|null $textAlign The text alignment. |
||
762 | * @return $this The current instance for a fluent interface. |
||
763 | */ |
||
764 | 1 | View Code Duplication | public function setAmountFrancsLeftAttr( |
796 | |||
797 | /** |
||
798 | * Set the right francs amount attributes |
||
799 | * |
||
800 | * @param float|null $posX The X position. |
||
801 | * @param float|null $posY The Y Position. |
||
802 | * @param float|null $width The width. |
||
803 | * @param float|null $height The height. |
||
804 | * @param string|null $background The background. |
||
805 | * @param string|null $fontFamily The font family. |
||
806 | * @param float|null $fontSize The font size. |
||
807 | * @param string|null $fontColor The font color. |
||
808 | * @param float|null $lineHeight The line height. |
||
809 | * @param string|null $textAlign The text alignment. |
||
810 | * @return $this The current instance for a fluent interface. |
||
811 | */ |
||
812 | 1 | View Code Duplication | public function setAmountFrancsRightAttr( |
844 | |||
845 | /** |
||
846 | * Set the left cents amount attributes |
||
847 | * |
||
848 | * @param float|null $posX The X position. |
||
849 | * @param float|null $posY The Y Position. |
||
850 | * @param float|null $width The width. |
||
851 | * @param float|null $height The height. |
||
852 | * @param string|null $background The background. |
||
853 | * @param string|null $fontFamily The font family. |
||
854 | * @param float|null $fontSize The font size. |
||
855 | * @param string|null $fontColor The font color. |
||
856 | * @param float|null $lineHeight The line height. |
||
857 | * @param string|null $textAlign The text alignment. |
||
858 | * @return $this The current instance for a fluent interface. |
||
859 | */ |
||
860 | 1 | View Code Duplication | public function setAmountCentsLeftAttr( |
888 | |||
889 | /** |
||
890 | * Set the right cents amount attributes |
||
891 | * |
||
892 | * @param float|null $posX The X position. |
||
893 | * @param float|null $posY The Y Position. |
||
894 | * @param float|null $width The width. |
||
895 | * @param float|null $height The height. |
||
896 | * @param string|null $background The background. |
||
897 | * @param string|null $fontFamily The font family. |
||
898 | * @param float|null $fontSize The font size. |
||
899 | * @param string|null $fontColor The font color. |
||
900 | * @param float|null $lineHeight The line height. |
||
901 | * @param string|null $textAlign The text alignment. |
||
902 | * @return $this The current instance for a fluent interface. |
||
903 | */ |
||
904 | 1 | View Code Duplication | public function setAmountCentsRightAttr( |
932 | |||
933 | /** |
||
934 | * Set the left payer attributes |
||
935 | * |
||
936 | * @param float|null $posX The X position. |
||
937 | * @param float|null $posY The Y Position. |
||
938 | * @param float|null $width The width. |
||
939 | * @param float|null $height The height. |
||
940 | * @param string|null $background The background. |
||
941 | * @param string|null $fontFamily The font family. |
||
942 | * @param float|null $fontSize The font size. |
||
943 | * @param string|null $fontColor The font color. |
||
944 | * @param float|null $lineHeight The line height. |
||
945 | * @param string|null $textAlign The text alignment. |
||
946 | * @return $this The current instance for a fluent interface. |
||
947 | */ |
||
948 | 1 | View Code Duplication | public function setPayerLeftAttr( |
976 | |||
977 | /** |
||
978 | * Set the right payer attributes |
||
979 | * |
||
980 | * @param float|null $posX The X position. |
||
981 | * @param float|null $posY The Y Position. |
||
982 | * @param float|null $width The width. |
||
983 | * @param float|null $height The height. |
||
984 | * @param string|null $background The background. |
||
985 | * @param string|null $fontFamily The font family. |
||
986 | * @param float|null $fontSize The font size. |
||
987 | * @param string|null $fontColor The font color. |
||
988 | * @param float|null $lineHeight The line height. |
||
989 | * @param string|null $textAlign The text alignment. |
||
990 | * @return $this The current instance for a fluent interface. |
||
991 | */ |
||
992 | 1 | View Code Duplication | public function setPayerRightAttr( |
1020 | |||
1021 | /** |
||
1022 | * Get the attributes of the left account element |
||
1023 | * |
||
1024 | * @return array The attributes of the left account element. |
||
1025 | */ |
||
1026 | 1 | public function getAccountLeftAttr() |
|
1030 | |||
1031 | /** |
||
1032 | * Get the attributes of the right account element |
||
1033 | * |
||
1034 | * @return array The attributes of the right account element. |
||
1035 | */ |
||
1036 | 1 | public function getAccountRightAttr() |
|
1040 | |||
1041 | /** |
||
1042 | * Get the attributes of the right cents amount element |
||
1043 | * |
||
1044 | * @return array The attributes of the right cents amount element. |
||
1045 | */ |
||
1046 | 1 | public function getAmountCentsRightAttr() |
|
1050 | |||
1051 | /** |
||
1052 | * Get the attributes of the left cents amount element |
||
1053 | * |
||
1054 | * @return array The attributes of the left cents amount element. |
||
1055 | */ |
||
1056 | 1 | public function getAmountCentsLeftAttr() |
|
1060 | |||
1061 | /** |
||
1062 | * Get the attributes of the left francs amount element |
||
1063 | * |
||
1064 | * @return array The attributes of the left francs amount element. |
||
1065 | */ |
||
1066 | 1 | public function getAmountFrancsLeftAttr() |
|
1070 | |||
1071 | /** |
||
1072 | * Get the attributes of the right francs amount element |
||
1073 | * |
||
1074 | * @return array The attributes of the right francs amount element. |
||
1075 | */ |
||
1076 | 1 | public function getAmountFrancsRightAttr() |
|
1080 | |||
1081 | /** |
||
1082 | * Get the attributes of the left bank element |
||
1083 | * |
||
1084 | * @return array The attributes of the left bank element. |
||
1085 | */ |
||
1086 | 1 | public function getBankLeftAttr() |
|
1090 | |||
1091 | /** |
||
1092 | * Get the attributes of the right bank element |
||
1093 | * |
||
1094 | * @return array The attributes of the right bank element. |
||
1095 | */ |
||
1096 | 1 | public function getBankRightAttr() |
|
1100 | |||
1101 | /** |
||
1102 | * Get the attributes of the right recipient element |
||
1103 | * |
||
1104 | * @return array The attributes of the right recipient element. |
||
1105 | */ |
||
1106 | 1 | public function getRecipientRightAttr() |
|
1110 | |||
1111 | /** |
||
1112 | * Get the attributes of the left recipient element |
||
1113 | * |
||
1114 | * @return array The attributes of the left recipient element. |
||
1115 | */ |
||
1116 | 1 | public function getRecipientLeftAttr() |
|
1120 | |||
1121 | /** |
||
1122 | * Get the attributes of the right payer element |
||
1123 | * |
||
1124 | * @return array The attributes of the right payer element. |
||
1125 | */ |
||
1126 | 1 | public function getPayerRightAttr() |
|
1130 | |||
1131 | /** |
||
1132 | * Get the attributes of the left payer element |
||
1133 | * |
||
1134 | * @return array The attributes of the left payer element. |
||
1135 | */ |
||
1136 | 1 | public function getPayerLeftAttr() |
|
1140 | |||
1141 | /** |
||
1142 | * Get the background of the slip |
||
1143 | * |
||
1144 | * Can be either 'transparent', a color or an image |
||
1145 | * |
||
1146 | * @return null|string The slip background. |
||
1147 | */ |
||
1148 | 1 | public function getSlipBackground() |
|
1152 | |||
1153 | /** |
||
1154 | * Get the starting X position of the slip |
||
1155 | * |
||
1156 | * @return int|float The starting X position of the slip. |
||
1157 | */ |
||
1158 | 1 | public function getSlipPosX() |
|
1162 | |||
1163 | /** |
||
1164 | * Get the starting Y position of the slip |
||
1165 | * |
||
1166 | * @return int|float The starting Y position of the slip. |
||
1167 | */ |
||
1168 | 1 | public function getSlipPosY() |
|
1172 | |||
1173 | /** |
||
1174 | * Get the width of the slip |
||
1175 | * |
||
1176 | * @return int|float The width of the slip. |
||
1177 | */ |
||
1178 | 1 | public function getSlipWidth() |
|
1182 | |||
1183 | /** |
||
1184 | * Get the height of the slip |
||
1185 | * |
||
1186 | * @return int|float The height of the slip. |
||
1187 | */ |
||
1188 | 1 | public function getSlipHeight() |
|
1192 | |||
1193 | /** |
||
1194 | * Set whether or not to display the background |
||
1195 | * |
||
1196 | * @param bool $displayBackground True if yes, false if no. |
||
1197 | * @return $this The current instance for a fluent interface.. |
||
1198 | */ |
||
1199 | 2 | public function setDisplayBackground($displayBackground = true) |
|
1206 | |||
1207 | /** |
||
1208 | * Get whether or not to display the background |
||
1209 | * |
||
1210 | * @return bool True if yes, false if no. |
||
1211 | */ |
||
1212 | 1 | public function getDisplayBackground() |
|
1216 | |||
1217 | /** |
||
1218 | * Set whether or not to display the account |
||
1219 | * |
||
1220 | * @param bool $displayAccount True if yes, false if no. |
||
1221 | * @return $this The current instance for a fluent interface.. |
||
1222 | */ |
||
1223 | 2 | public function setDisplayAccount($displayAccount = true) |
|
1230 | |||
1231 | /** |
||
1232 | * Get whether or not to display the account |
||
1233 | * |
||
1234 | * @return bool True if yes, false if no. |
||
1235 | */ |
||
1236 | 1 | public function getDisplayAccount() |
|
1243 | |||
1244 | /** |
||
1245 | * Set whether or not to display the amount |
||
1246 | * |
||
1247 | * @param bool $displayAmount True if yes, false if no |
||
1248 | * @return $this The current instance for a fluent interface. |
||
1249 | */ |
||
1250 | 2 | public function setDisplayAmount($displayAmount = true) |
|
1257 | |||
1258 | /** |
||
1259 | * Get whether or not to display the amount |
||
1260 | * |
||
1261 | * @return bool True if yes, false if no. |
||
1262 | */ |
||
1263 | 1 | public function getDisplayAmount() |
|
1270 | |||
1271 | /** |
||
1272 | * Set whether or not to display the bank |
||
1273 | * |
||
1274 | * @param bool $displayBank True if yes, false if no |
||
1275 | * @return $this The current instance for a fluent interface. |
||
1276 | */ |
||
1277 | 2 | public function setDisplayBank($displayBank = true) |
|
1284 | |||
1285 | /** |
||
1286 | * Get whether or not to display the bank |
||
1287 | * |
||
1288 | * @return bool True if yes, false if no. |
||
1289 | */ |
||
1290 | 1 | public function getDisplayBank() |
|
1297 | |||
1298 | /** |
||
1299 | * Set whether or not to display the payer |
||
1300 | * |
||
1301 | * @param bool $displayPayer True if yes, false if no |
||
1302 | * @return $this The current instance for a fluent interface. |
||
1303 | */ |
||
1304 | 2 | public function setDisplayPayer($displayPayer = true) |
|
1311 | |||
1312 | /** |
||
1313 | * Get whether or not to display the payer |
||
1314 | * |
||
1315 | * @return bool True if yes, false if no. |
||
1316 | */ |
||
1317 | 1 | public function getDisplayPayer() |
|
1324 | |||
1325 | /** |
||
1326 | * Set whether or not to display the recipient |
||
1327 | * |
||
1328 | * @param bool $displayRecipient True if yes, false if no |
||
1329 | * @return $this The current instance for a fluent interface. |
||
1330 | */ |
||
1331 | 2 | public function setDisplayRecipient($displayRecipient = true) |
|
1338 | |||
1339 | /** |
||
1340 | * Get whether or not to display the recipient |
||
1341 | * |
||
1342 | * @return bool True if yes, false if no. |
||
1343 | */ |
||
1344 | 1 | public function getDisplayRecipient() |
|
1351 | |||
1352 | /** |
||
1353 | * Get all elements of the slip |
||
1354 | * |
||
1355 | * @return array All elements with their lines and attributes. |
||
1356 | */ |
||
1357 | 3 | public function getAllElements() |
|
1471 | |||
1472 | /** |
||
1473 | * Verify that a given parameter is an integer or a float |
||
1474 | * |
||
1475 | * @param mixed $parameter The given parameter to validate. |
||
1476 | * @param string $varName The name of the variable. |
||
1477 | * @return true If the parameter is either an integer or a float. |
||
1478 | * @throws InvalidArgumentException If the parameter is neither an integer nor a float. |
||
1479 | */ |
||
1480 | 4 | protected function isIntOrFloat($parameter, $varName) |
|
1491 | |||
1492 | /** |
||
1493 | * Verify that a given parameter is boolean |
||
1494 | * |
||
1495 | * @param mixed $parameter The given parameter to validate. |
||
1496 | * @param string $varName The name of the variable. |
||
1497 | * @return true If the parameter is a boolean. |
||
1498 | * @throws InvalidArgumentException If the parameter is not a boolean. |
||
1499 | */ |
||
1500 | 20 | protected function isBool($parameter, $varName) |
|
1512 | } |
||
1513 |
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.