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 | View Code Duplication | final class EchoAction extends AbstractAction |
|
| 18 | { |
||
| 19 | /** The constant that defines the output socket. */ |
||
| 20 | const SOCKET_OUTPUT = 'out'; |
||
| 21 | |||
| 22 | /** The socket that holds the data variable. */ |
||
| 23 | const SOCKET_DATA = 'data'; |
||
| 24 | |||
| 25 | /** |
||
| 26 | * Initializes a new instance of this class. |
||
| 27 | */ |
||
| 28 | public function __construct() |
||
| 35 | |||
| 36 | /** |
||
| 37 | * Executes the node's logic. |
||
| 38 | */ |
||
| 39 | public function execute() |
||
| 50 | } |
||
| 51 |