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 declare(strict_types=1); |
||
| 9 | class DailymotionServiceAdapter extends AbstractServiceAdapter |
||
| 10 | { |
||
| 11 | const THUMBNAIL_DEFAULT = 'thumbnail'; |
||
| 12 | |||
| 13 | public function __construct(string $url, string $pattern, EmbedRendererInterface $renderer) |
||
| 20 | |||
| 21 | public function getServiceName(): string |
||
| 25 | |||
| 26 | public function hasThumbnail(): bool |
||
| 30 | |||
| 31 | public function getThumbNailSizes(): array |
||
| 37 | |||
| 38 | /** |
||
| 39 | * @throws InvalidThumbnailSizeException |
||
| 40 | * @throws \RicardoFiorani\Adapter\Exception\InvalidUrlException |
||
| 41 | */ |
||
| 42 | View Code Duplication | public function getThumbnail(string $size, bool $forceSecure = false): string |
|
| 50 | |||
| 51 | /** |
||
| 52 | * @throws InvalidThumbnailSizeException |
||
| 53 | * @throws \RicardoFiorani\Adapter\Exception\InvalidUrlException |
||
| 54 | */ |
||
| 55 | public function getSmallThumbnail(bool $forceSecure = false): string |
||
| 60 | |||
| 61 | /** |
||
| 62 | * @throws InvalidThumbnailSizeException |
||
| 63 | * @throws \RicardoFiorani\Adapter\Exception\InvalidUrlException |
||
| 64 | */ |
||
| 65 | public function getMediumThumbnail(bool $forceSecure = false): string |
||
| 70 | |||
| 71 | /** |
||
| 72 | * @throws InvalidThumbnailSizeException |
||
| 73 | * @throws \RicardoFiorani\Adapter\Exception\InvalidUrlException |
||
| 74 | */ |
||
| 75 | public function getLargeThumbnail(bool $forceSecure = false): string |
||
| 80 | |||
| 81 | /** |
||
| 82 | * @throws InvalidThumbnailSizeException |
||
| 83 | * @throws \RicardoFiorani\Adapter\Exception\InvalidUrlException |
||
| 84 | */ |
||
| 85 | public function getLargestThumbnail(bool $forceSecure = false): string |
||
| 90 | |||
| 91 | /** |
||
| 92 | * @throws \RicardoFiorani\Adapter\Exception\InvalidUrlException |
||
| 93 | */ |
||
| 94 | public function getEmbedUrl(bool $forceAutoplay = false, bool $forceSecure = false): string |
||
| 98 | |||
| 99 | public function isEmbeddable(): bool |
||
| 103 | } |
||
| 104 |