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 | View Code Duplication | class OperationQuery extends Query implements IOperationQuery |
|
11 | { |
||
12 | /** |
||
13 | * @var IOperation |
||
14 | */ |
||
15 | private $operation; |
||
16 | |||
17 | public function __construct(IScope $scope, IOperation $operation) |
||
18 | { |
||
19 | parent::__construct($scope, $operation->getParameters()); |
||
20 | $this->operation = $operation; |
||
21 | } |
||
22 | |||
23 | public function getOperation() |
||
27 | |||
28 | public function update(IScope $scope, IOperation $operation) |
||
36 | |||
37 | public function updateOperation(IOperation $operation) |
||
41 | |||
42 | protected function withScope(IScope $scope) |
||
46 | } |
||
47 |