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 |
||
| 20 | class ArrayIterator extends AbstractResultsIterator |
||
| 21 | { |
||
| 22 | /** |
||
| 23 | * @var array |
||
| 24 | */ |
||
| 25 | private $aggregations; |
||
|
|
|||
| 26 | |||
| 27 | /** |
||
| 28 | * {@inheritdoc} |
||
| 29 | */ |
||
| 30 | View Code Duplication | public function __construct(array $rawData, Manager $manager, array $scroll = []) |
|
| 39 | |||
| 40 | /** |
||
| 41 | * Returns aggregations. |
||
| 42 | * |
||
| 43 | * @return array |
||
| 44 | */ |
||
| 45 | public function getAggregations() |
||
| 49 | |||
| 50 | /** |
||
| 51 | * Get a specific aggregation by name. It fetches from the top level only. |
||
| 52 | * |
||
| 53 | * @param string $name |
||
| 54 | * |
||
| 55 | * @return AggregationValue|null |
||
| 56 | */ |
||
| 57 | public function getAggregation($name) |
||
| 65 | |||
| 66 | /** |
||
| 67 | * {@inheritdoc} |
||
| 68 | */ |
||
| 69 | protected function convertDocument(array $document) |
||
| 73 | } |
||
| 74 |