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 |
||
17 | final class ReplaceAction extends AbstractAction |
||
18 | { |
||
19 | /** The output socket. */ |
||
20 | const SOCKET_OUTPUT = 'out'; |
||
21 | |||
22 | /** The pattern variable socket. */ |
||
23 | const SOCKET_PATTERN = 'pattern'; |
||
24 | |||
25 | /** The replacement variable socket. */ |
||
26 | const SOCKET_REPLACEMENT = 'replacement'; |
||
27 | |||
28 | /** The subject variable socket. */ |
||
29 | const SOCKET_SUBJECT = 'subject'; |
||
30 | |||
31 | /** The result variable socket. */ |
||
32 | const SOCKET_RESULT = 'result'; |
||
33 | |||
34 | /** |
||
35 | * Initializes a new instance of this class. |
||
36 | */ |
||
37 | View Code Duplication | public function __construct() |
|
47 | |||
48 | /** |
||
49 | * Executes the node's logic. |
||
50 | */ |
||
51 | public function execute() |
||
79 | } |
||
80 |