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 YoutubeServiceAdapter extends AbstractServiceAdapter |
||
| 10 | { |
||
| 11 | const THUMBNAIL_DEFAULT = 'default'; |
||
| 12 | const THUMBNAIL_STANDARD_DEFINITION = 'sddefault'; |
||
| 13 | const THUMBNAIL_MEDIUM_QUALITY = 'mqdefault'; |
||
| 14 | const THUMBNAIL_HIGH_QUALITY = 'hqdefault'; |
||
| 15 | const THUMBNAIL_MAX_QUALITY = 'maxresdefault'; |
||
| 16 | |||
| 17 | 15 | public function __construct(string $url, string $pattern, EmbedRendererInterface $renderer) |
|
| 30 | |||
| 31 | 1 | public function getServiceName(): string |
|
| 35 | |||
| 36 | 1 | public function hasThumbnail(): bool |
|
| 40 | |||
| 41 | /** |
||
| 42 | * @throws InvalidThumbnailSizeException |
||
| 43 | */ |
||
| 44 | 2 | View Code Duplication | public function getThumbnail(string $size, bool $forceSecure = false): string |
| 52 | |||
| 53 | 3 | public function getThumbNailSizes(): array |
|
| 63 | |||
| 64 | 2 | public function getEmbedUrl(bool $forceAutoplay = false, bool $forceSecure = false): string |
|
| 75 | |||
| 76 | 1 | public function getSmallThumbnail(bool $forceSecure = false): string |
|
| 80 | |||
| 81 | 1 | public function getMediumThumbnail(bool $forceSecure = false): string |
|
| 85 | |||
| 86 | 1 | public function getLargeThumbnail(bool $forceSecure = false): string |
|
| 90 | |||
| 91 | 1 | public function getLargestThumbnail(bool $forceSecure = false): string |
|
| 95 | |||
| 96 | 1 | public function isEmbeddable(): bool |
|
| 100 | |||
| 101 | 2 | private function generateQuerystring(bool $forceAutoplay = false): array |
|
| 112 | } |
||
| 113 |