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 |
||
| 27 | class ArticleProvider implements ArticleProviderInterface |
||
|
|
|||
| 28 | { |
||
| 29 | /** |
||
| 30 | * @var ArticleRepositoryInterface |
||
| 31 | */ |
||
| 32 | private $articleRepository; |
||
| 33 | |||
| 34 | /** |
||
| 35 | * @var TenantAwarePathBuilderInterface |
||
| 36 | */ |
||
| 37 | private $pathBuilder; |
||
| 38 | |||
| 39 | /** |
||
| 40 | * @var string |
||
| 41 | */ |
||
| 42 | private $basePath; |
||
| 43 | |||
| 44 | /** |
||
| 45 | * ArticleProvider constructor. |
||
| 46 | * |
||
| 47 | * @param ArticleRepositoryInterface $articleRepository |
||
| 48 | * @param TenantAwarePathBuilderInterface $pathBuilder |
||
| 49 | * @param string $basePath |
||
| 50 | */ |
||
| 51 | public function __construct( |
||
| 60 | |||
| 61 | /** |
||
| 62 | * {@inheritdoc} |
||
| 63 | */ |
||
| 64 | public function getBaseNode() |
||
| 68 | |||
| 69 | /** |
||
| 70 | * {@inheritdoc} |
||
| 71 | */ |
||
| 72 | View Code Duplication | public function getOneById($id) |
|
| 80 | |||
| 81 | /** |
||
| 82 | * {@inheritdoc} |
||
| 83 | */ |
||
| 84 | public function getParent($id) |
||
| 88 | |||
| 89 | /** |
||
| 90 | * {@inheritdoc} |
||
| 91 | */ |
||
| 92 | public function getTenantArticlesQuery(string $tenantContentIdentifier, array $order) : SqlQuery |
||
| 96 | |||
| 97 | /** |
||
| 98 | * {@inheritdoc} |
||
| 99 | */ |
||
| 100 | public function getRouteArticlesQuery(string $routeIdentifier, array $order) : SqlQuery |
||
| 104 | } |
||
| 105 |