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:
| 1 | <?php |
||
| 36 | class TInlineFrame extends \Prado\Web\UI\WebControls\TWebControl implements \Prado\IDataRenderer |
||
| 37 | { |
||
| 38 | /** |
||
| 39 | * @return string tag name of the iframe. |
||
| 40 | */ |
||
| 41 | protected function getTagName() |
||
| 45 | |||
| 46 | /** |
||
| 47 | * @return TInlineFrameAlign alignment of the iframe. Defaults to TInlineFrameAlign::NotSet. |
||
| 48 | */ |
||
| 49 | public function getAlign() |
||
| 53 | |||
| 54 | /** |
||
| 55 | * @param TInlineFrameAlign $value alignment of the iframe. |
||
| 56 | */ |
||
| 57 | public function setAlign($value) |
||
| 61 | |||
| 62 | /** |
||
| 63 | * @return string the URL to long description |
||
| 64 | */ |
||
| 65 | public function getDescriptionUrl() |
||
| 69 | |||
| 70 | /** |
||
| 71 | * @param string $value the URL to the long description of the image. |
||
| 72 | */ |
||
| 73 | public function setDescriptionUrl($value) |
||
| 77 | |||
| 78 | /** |
||
| 79 | * @return bool whether there should be a visual separator between the frames. Defaults to true. |
||
| 80 | */ |
||
| 81 | public function getShowBorder() |
||
| 85 | |||
| 86 | /** |
||
| 87 | * @param bool $value whether there should be a visual separator between the frames. |
||
| 88 | */ |
||
| 89 | public function setShowBorder($value) |
||
| 93 | |||
| 94 | /** |
||
| 95 | * @return string URL that this iframe will load content from. Defaults to ''. |
||
| 96 | */ |
||
| 97 | public function getFrameUrl() |
||
| 101 | |||
| 102 | /** |
||
| 103 | * @param string $value URL that this iframe will load content from. |
||
| 104 | */ |
||
| 105 | public function setFrameUrl($value) |
||
| 109 | |||
| 110 | /** |
||
| 111 | * Returns the URL that this iframe will load content from |
||
| 112 | * This method is required by {@link \Prado\IDataRenderer}. |
||
| 113 | * It is the same as {@link getFrameUrl()}. |
||
| 114 | * @return string the URL that this iframe will load content from |
||
| 115 | * @see getFrameUrl |
||
| 116 | * @since 3.1.0 |
||
| 117 | */ |
||
| 118 | public function getData() |
||
| 122 | |||
| 123 | /** |
||
| 124 | * Sets the URL that this iframe will load content from. |
||
| 125 | * This method is required by {@link \Prado\IDataRenderer}. |
||
| 126 | * It is the same as {@link setFrameUrl()}. |
||
| 127 | * @param string $value the URL that this iframe will load content from |
||
| 128 | * @see setFrameUrl |
||
| 129 | * @since 3.1.0 |
||
| 130 | */ |
||
| 131 | public function setData($value) |
||
| 135 | |||
| 136 | /** |
||
| 137 | * @return TInlineFrameScrollBars the visibility and position of scroll bars in an iframe. Defaults to TInlineFrameScrollBars::Auto. |
||
| 138 | */ |
||
| 139 | public function getScrollBars() |
||
| 143 | |||
| 144 | /** |
||
| 145 | * @param TInlineFrameScrollBars $value the visibility and position of scroll bars in an iframe. |
||
| 146 | */ |
||
| 147 | public function setScrollBars($value) |
||
| 151 | |||
| 152 | /** |
||
| 153 | * @return int the width of the control |
||
| 154 | */ |
||
| 155 | public function getWidth() |
||
| 159 | |||
| 160 | /** |
||
| 161 | * @param int $value the width of the control |
||
| 162 | */ |
||
| 163 | View Code Duplication | public function setWidth($value) |
|
| 170 | |||
| 171 | /** |
||
| 172 | * @return int the height of the control |
||
| 173 | */ |
||
| 174 | public function getHeight() |
||
| 178 | |||
| 179 | /** |
||
| 180 | * @param int $value the height of the control |
||
| 181 | */ |
||
| 182 | View Code Duplication | public function setHeight($value) |
|
| 189 | |||
| 190 | /** |
||
| 191 | * @return int the amount of space, in pixels, that should be left between |
||
| 192 | * the frame's contents and the left and right margins. Defaults to -1, meaning not set. |
||
| 193 | */ |
||
| 194 | public function getMarginWidth() |
||
| 198 | |||
| 199 | /** |
||
| 200 | * @param int $value the amount of space, in pixels, that should be left between |
||
| 201 | * the frame's contents and the left and right margins. |
||
| 202 | */ |
||
| 203 | View Code Duplication | public function setMarginWidth($value) |
|
| 210 | |||
| 211 | /** |
||
| 212 | * @return int the amount of space, in pixels, that should be left between |
||
| 213 | * the frame's contents and the top and bottom margins. Defaults to -1, meaning not set. |
||
| 214 | */ |
||
| 215 | public function getMarginHeight() |
||
| 219 | |||
| 220 | /** |
||
| 221 | * @param int $value the amount of space, in pixels, that should be left between |
||
| 222 | * the frame's contents and the top and bottom margins. |
||
| 223 | */ |
||
| 224 | View Code Duplication | public function setMarginHeight($value) |
|
| 231 | |||
| 232 | /** |
||
| 233 | * Adds attribute name-value pairs to renderer. |
||
| 234 | * This overrides the parent implementation with additional button specific attributes. |
||
| 235 | * @param THtmlWriter $writer the writer used for the rendering purpose |
||
| 236 | */ |
||
| 237 | protected function addAttributesToRender($writer) |
||
| 284 | } |
||
| 285 |
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.