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 IfCondition extends AbstractAction |
||
| 18 | { |
||
| 19 | /** The output socket that is activated when the values are equal. */ |
||
| 20 | const SOCKET_EQUAL = 'equal'; |
||
| 21 | |||
| 22 | /** The output socket that is activated when the values are not equal. */ |
||
| 23 | const SOCKET_NOT_EQUAL = 'not-equal'; |
||
| 24 | |||
| 25 | /** The output socket that is activated when the left value is less than the right value. */ |
||
| 26 | const SOCKET_LESS_THAN = 'less-than'; |
||
| 27 | |||
| 28 | /** The output socket that is activated when the left value is greater than the right value. */ |
||
| 29 | const SOCKET_GREATER_THAN = 'greater-than'; |
||
| 30 | |||
| 31 | /** The left value to compare. */ |
||
| 32 | const SOCKET_VALUELFT = 'value-lft'; |
||
| 33 | |||
| 34 | /** The right value to compare. */ |
||
| 35 | const SOCKET_VALUERGT = 'value-rgt'; |
||
| 36 | |||
| 37 | /** |
||
| 38 | * Initializes a new instance of this class. |
||
| 39 | */ |
||
| 40 | View Code Duplication | public function __construct() |
|
| 51 | |||
| 52 | /** |
||
| 53 | * Executes the node's logic. |
||
| 54 | */ |
||
| 55 | public function execute() |
||
| 72 | } |
||
| 73 |