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 |
||
24 | View Code Duplication | class MissingParameterException extends RuntimeException |
|
25 | { |
||
26 | /** |
||
27 | * Creates a new exception for the given parameter name. |
||
28 | * |
||
29 | * @param string $parameterName The name of the parameter that was |
||
30 | * missing. |
||
31 | * @param string $typeName The name of the type that the |
||
32 | * parameter was searched on. |
||
33 | * @param Exception|null $cause The exception that caused this |
||
34 | * exception. |
||
35 | * |
||
36 | * @return static The created exception. |
||
37 | */ |
||
38 | 1 | public static function forParameterName($parameterName, $typeName, Exception $cause = null) |
|
46 | } |
||
47 |