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 |
||
| 34 | class OrPointcut extends AbstractConnectorPointcut |
||
| 35 | { |
||
| 36 | /** |
||
| 37 | * Connector which connects two pointcuts in a logical manner |
||
| 38 | * |
||
| 39 | * @var string CONNECTOR |
||
| 40 | */ |
||
| 41 | const CONNECTOR = self::CONNECTOR_OR; |
||
| 42 | |||
| 43 | /** |
||
| 44 | * The type of this pointcut |
||
| 45 | * |
||
| 46 | * @var string TYPE |
||
| 47 | */ |
||
| 48 | const TYPE = 'or'; |
||
| 49 | |||
| 50 | /** |
||
| 51 | * Returns a string representing a boolean condition which can be used to determine if |
||
| 52 | * the pointcut has to be executed |
||
| 53 | * |
||
| 54 | * @return string |
||
| 55 | */ |
||
| 56 | public function getConditionString() |
||
| 67 | |||
| 68 | /** |
||
| 69 | * Whether or not the pointcut matches a given candidate. |
||
| 70 | * For connector pointcuts this mostly depends on the connected pointcuts |
||
| 71 | * |
||
| 72 | * @param mixed $candidate Candidate to match against the pointcuts match pattern (getMatchPattern()) |
||
| 73 | * |
||
| 74 | * @return boolean |
||
| 75 | */ |
||
| 76 | public function matches($candidate) |
||
| 80 | } |
||
| 81 |