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 | ||
| 19 | class Name extends Property { | ||
| 20 | /** | ||
| 21 | * Name of the property. | ||
| 22 | * | ||
| 23 | * @return string | ||
| 24 | */ | ||
| 25 | 34 |     public function name() { | |
| 28 | |||
| 29 | /** | ||
| 30 | * Fetch arguments for the Property from a stream of tokens during parsing. | ||
| 31 | * | ||
| 32 | * @param ArgumentParser $parser | ||
| 33 | * @return array | ||
| 34 | */ | ||
| 35 | 7 |     public function fetch_arguments(ArgumentParser $parser) { | |
| 39 | |||
| 40 | /** | ||
| 41 | * Check if the given arguments are valid for the property. | ||
| 42 | * | ||
| 43 | * @param array $arguments | ||
| 44 | * @return bool | ||
| 45 | */ | ||
| 46 | 36 | View Code Duplication |     public function arguments_are_valid(array &$arguments) { | 
| 56 | |||
| 57 | /** | ||
| 58 | * Compile the property to an SQL expression. | ||
| 59 | * | ||
| 60 | * @param array $argument | ||
| 61 | * @param ExpressionBuilder $builder | ||
| 62 | * @param string $table_name | ||
| 63 | * @param bool $negate | ||
| 64 | * @return string|CompositeExpression | ||
| 65 | */ | ||
| 66 | 29 |     public function compile(array &$arguments, ExpressionBuilder $builder, $table_name, $negate = false) { | |
| 75 | } | ||
| 76 |