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 |
||
| 32 | class PackageSeoMediaUploadController extends AbstractController |
||
| 33 | { |
||
| 34 | private $seoMetadataFactory; |
||
| 35 | |||
| 36 | private $seoMetadataRepository; |
||
| 37 | |||
| 38 | public function __construct( |
||
| 45 | |||
| 46 | /** |
||
| 47 | * @Operation( |
||
| 48 | * tags={"seo"}, |
||
| 49 | * summary="Uploads SEO image for Package", |
||
| 50 | * @SWG\Parameter( |
||
| 51 | * name="metaMediaFile", |
||
| 52 | * in="formData", |
||
| 53 | * description="", |
||
| 54 | * required=false, |
||
| 55 | * type="file" |
||
| 56 | * ), |
||
| 57 | * @SWG\Parameter( |
||
| 58 | * name="ogMediaFile", |
||
| 59 | * in="formData", |
||
| 60 | * description="", |
||
| 61 | * required=false, |
||
| 62 | * type="file" |
||
| 63 | * ), |
||
| 64 | * @SWG\Parameter( |
||
| 65 | * name="twitterMediaFile", |
||
| 66 | * in="formData", |
||
| 67 | * description="", |
||
| 68 | * required=false, |
||
| 69 | * type="file" |
||
| 70 | * ), |
||
| 71 | * @SWG\Response( |
||
| 72 | * response="201", |
||
| 73 | * description="Returned on success.", |
||
| 74 | * @Model(type=\SWP\Bundle\ContentBundle\Model\ArticleSeoMetadata::class, groups={"api"}) |
||
| 75 | * ) |
||
| 76 | * ) |
||
| 77 | * |
||
| 78 | * @Route("/api/{version}/packages/seo/upload/{packageGuid}", options={"expose"=true}, defaults={"version"="v2"}, methods={"POST"}, name="swp_api_upload_package_seo_image") |
||
| 79 | * |
||
| 80 | * @param Request $request |
||
| 81 | * |
||
| 82 | * @return SingleResourceResponse |
||
| 83 | */ |
||
| 84 | public function uploadAction(Request $request, string $packageGuid, SeoImageUploaderInterface $seoImageUploader): SingleResourceResponse |
||
| 110 | } |
||
| 111 |
This check marks calls to methods that do not seem to exist on an object.
This is most likely the result of a method being renamed without all references to it being renamed likewise.