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 |
||
| 35 | class AnnotationParameterDefinition { |
||
| 36 | |||
| 37 | /** @var string */ |
||
| 38 | private $name; |
||
| 39 | |||
| 40 | /** @var string */ |
||
| 41 | private $type; |
||
| 42 | |||
| 43 | /** @var boolean */ |
||
| 44 | private $required; |
||
| 45 | |||
| 46 | /** |
||
| 47 | * Class constructor. |
||
| 48 | * @param string $name |
||
| 49 | * @param string $type |
||
| 50 | * @param boolean $required |
||
| 51 | * @throws \InvalidArgumentException |
||
| 52 | */ |
||
| 53 | 1 | View Code Duplication | public function __construct($name, $type, $required = true) { |
| 61 | |||
| 62 | /** |
||
| 63 | * Returns the parameter name. |
||
| 64 | * @return string the parameter name |
||
| 65 | */ |
||
| 66 | 1 | public function getName() { |
|
| 69 | |||
| 70 | /** |
||
| 71 | * Returns the parameter type. |
||
| 72 | * @return string the parameter type |
||
| 73 | */ |
||
| 74 | 1 | public function getType() { |
|
| 77 | |||
| 78 | /** |
||
| 79 | * Checks if the parameter is required. |
||
| 80 | * @return boolean check result |
||
| 81 | */ |
||
| 82 | 1 | public function isRequired() { |
|
| 85 | |||
| 86 | } |
||
| 87 |