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 |
||
19 | class ObjectIterator extends Collection |
||
|
|||
20 | { |
||
21 | /** |
||
22 | * @var Converter |
||
23 | */ |
||
24 | private $converter; |
||
25 | |||
26 | /** |
||
27 | * @var array Aliases information. |
||
28 | */ |
||
29 | private $alias; |
||
30 | |||
31 | /** |
||
32 | * @var array |
||
33 | */ |
||
34 | private $rawObjects; |
||
35 | |||
36 | /** |
||
37 | * @var \Closure |
||
38 | */ |
||
39 | private $convertCallback; |
||
40 | |||
41 | /** |
||
42 | * Using part of abstract iterator functionality only. |
||
43 | * |
||
44 | * @param Converter $converter |
||
45 | * @param array $objects |
||
46 | * @param array $alias |
||
47 | */ |
||
48 | public function __construct($converter, $objects, $alias) |
||
69 | |||
70 | /** |
||
71 | * {@inheritdoc} |
||
72 | */ |
||
73 | protected function convertDocument(array $document) |
||
81 | |||
82 | /** |
||
83 | * Converts a raw object when the key for the object must be determined first. |
||
84 | * |
||
85 | * @param array $rawObject |
||
86 | * |
||
87 | * @return bool|object |
||
88 | */ |
||
89 | protected function convertFromValue(array $rawObject) { |
||
97 | |||
98 | /** |
||
99 | * {@inheritdoc} |
||
100 | */ |
||
101 | public function getIterator() |
||
106 | |||
107 | View Code Duplication | public function first() |
|
117 | |||
118 | View Code Duplication | public function last() |
|
129 | |||
130 | /** |
||
131 | * {@inheritdoc} |
||
132 | */ |
||
133 | View Code Duplication | public function get($offset) |
|
145 | |||
146 | /** |
||
147 | * {@inheritdoc} |
||
148 | */ |
||
149 | protected function createFrom(array $elements) |
||
153 | } |
||
154 |
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.