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 | View Code Duplication | class ForceRedirect extends \Exception implements Exception |
|
22 | { |
||
23 | use AccessorTrait; |
||
24 | |||
25 | private $location; |
||
26 | |||
27 | protected function get_location() |
||
31 | |||
32 | public function __construct($location, $code = Status::FOUND, \Exception $previous = null) |
||
38 | |||
39 | /** |
||
40 | * Formats exception message. |
||
41 | * |
||
42 | * @param string $location |
||
43 | * |
||
44 | * @return string |
||
45 | */ |
||
46 | protected function format_message($location) |
||
50 | } |
||
51 |