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 |
||
21 | class Limit extends Component |
||
22 | { |
||
23 | /** |
||
24 | * The number of rows skipped. |
||
25 | * |
||
26 | * @var int |
||
27 | */ |
||
28 | public $offset; |
||
29 | |||
30 | /** |
||
31 | * The number of rows to be returned. |
||
32 | * |
||
33 | * @var int |
||
34 | */ |
||
35 | public $rowCount; |
||
36 | |||
37 | /** |
||
38 | * Constructor. |
||
39 | * |
||
40 | * @param int $rowCount the row count |
||
41 | * @param int $offset the offset |
||
42 | */ |
||
43 | 21 | public function __construct($rowCount = 0, $offset = 0) |
|
48 | |||
49 | /** |
||
50 | * @param Parser $parser the parser that serves as context |
||
51 | * @param TokensList $list the list of tokens that are being parsed |
||
52 | * @param array $options parameters for parsing |
||
53 | * |
||
54 | * @return Limit |
||
55 | */ |
||
56 | 18 | public static function parse(Parser $parser, TokensList $list, array $options = array()) |
|
117 | |||
118 | /** |
||
119 | * @param Limit $component the component to be built |
||
120 | * @param array $options parameters for building |
||
121 | * |
||
122 | * @return string |
||
123 | */ |
||
124 | 5 | public static function build($component, array $options = array()) |
|
128 | } |
||
129 |