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 |
||
| 8 | class RepeaterFile |
||
| 9 | { |
||
| 10 | /** |
||
| 11 | * @var File |
||
| 12 | */ |
||
| 13 | private $field; |
||
| 14 | |||
| 15 | public function __construct(File $field) |
||
| 19 | |||
| 20 | public function __call($method, $parameters) |
||
| 24 | |||
| 25 | View Code Duplication | public function getPaths($model): array |
|
| 40 | |||
| 41 | private function sanitizeRepeaterValue($filepath) |
||
| 49 | } |
||
| 50 |
Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a
@returnannotation as described here.