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 |
||
| 10 | |||
| 11 | final class UseNamespaceScoperNodeVisitor extends NodeVisitorAbstract |
||
| 12 | { |
||
| 13 | /** |
||
| 14 | * @var string |
||
| 15 | */ |
||
| 16 | private $prefix; |
||
| 17 | |||
| 18 | public function __construct($prefix) |
||
| 22 | |||
| 23 | /** |
||
| 24 | * @inheritdoc |
||
| 25 | */ |
||
| 26 | public function enterNode(Node $node) |
||
| 27 | { |
||
| 28 | if ($node instanceof UseUse |
||
| 29 | && $node->hasAttribute('parent') && false === ($node->getAttribute('parent') instanceof GroupUse) |
||
| 38 |