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 |
||
| 16 | class ExceptionConversion extends Gateway |
||
| 17 | { |
||
| 18 | /** |
||
| 19 | * The wrapped gateway. |
||
| 20 | * |
||
| 21 | * @var Gateway |
||
| 22 | */ |
||
| 23 | protected $innerGateway; |
||
| 24 | |||
| 25 | /** |
||
| 26 | * ExceptionConversion constructor. |
||
| 27 | * |
||
| 28 | * @param \eZ\Publish\Core\Persistence\Legacy\URL\Gateway $innerGateway |
||
| 29 | */ |
||
| 30 | public function __construct(Gateway $innerGateway) |
||
| 34 | |||
| 35 | /** |
||
| 36 | * {@inheritdoc} |
||
| 37 | */ |
||
| 38 | View Code Duplication | public function updateUrl(URL $url) |
|
| 48 | |||
| 49 | /** |
||
| 50 | * {@inheritdoc} |
||
| 51 | */ |
||
| 52 | View Code Duplication | public function find(Criterion $criterion, $offset, $limit, array $sortClauses = [], $doCount = true) |
|
| 62 | |||
| 63 | /** |
||
| 64 | * {@inheritdoc} |
||
| 65 | */ |
||
| 66 | View Code Duplication | public function findUsages($id) |
|
| 76 | |||
| 77 | /** |
||
| 78 | * {@inheritdoc} |
||
| 79 | */ |
||
| 80 | View Code Duplication | public function loadUrlData($id) |
|
| 90 | |||
| 91 | /** |
||
| 92 | * {@inheritdoc} |
||
| 93 | */ |
||
| 94 | View Code Duplication | public function loadUrlDataByUrl($url) |
|
| 104 | } |
||
| 105 |