| Total Complexity | 6 |
| Total Lines | 65 |
| Duplicated Lines | 0 % |
| Coverage | 57.14% |
| Changes | 0 | ||
| 1 | <?php |
||
| 13 | abstract class AbstractManipulator implements ManipulatorInterface |
||
| 14 | { |
||
| 15 | /** |
||
| 16 | * @param Media $media |
||
| 17 | * |
||
| 18 | * @return bool |
||
| 19 | */ |
||
| 20 | 4 | public function canConvert(Media $media): bool |
|
| 21 | { |
||
| 22 | 4 | if (!$this->requirementsAreInstalled()) { |
|
| 23 | return false; |
||
|
|
|||
| 24 | } |
||
| 25 | |||
| 26 | 4 | if (!$this->supportedExtensions()->contains(strtolower($media->getExtension()))) { |
|
| 27 | 1 | return false; |
|
| 28 | } |
||
| 29 | // $urlGenerator = UrlGeneratorFactory::createForMedia($media); |
||
| 30 | // if (method_exists($urlGenerator, 'getPath') && file_exists($media->getPath()) |
||
| 31 | // && $this->supportedMimetypes()->contains(strtolower(File::getMimetype($media->getPath())))) { |
||
| 32 | // return true; |
||
| 33 | // } |
||
| 34 | 3 | return true; |
|
| 35 | } |
||
| 36 | |||
| 37 | /** |
||
| 38 | * @param ConversionCollection $conversions |
||
| 39 | * @param Media $media |
||
| 40 | * |
||
| 41 | * @return int Number of convertions performed |
||
| 42 | */ |
||
| 43 | 3 | public function performConversions(ConversionCollection $conversions, Media $media) |
|
| 56 | } |
||
| 57 | |||
| 58 | /** |
||
| 59 | * @param Media $media |
||
| 60 | * @param Conversion $conversion |
||
| 61 | */ |
||
| 62 | abstract public function performConversion(Media $media, Conversion $conversion); |
||
| 63 | |||
| 64 | /** |
||
| 65 | * @return bool |
||
| 66 | */ |
||
| 67 | abstract public function requirementsAreInstalled(): bool; |
||
| 68 | |||
| 69 | /** |
||
| 70 | * @return Collection |
||
| 71 | */ |
||
| 72 | abstract public function supportedExtensions(): Collection; |
||
| 73 | |||
| 74 | /** |
||
| 75 | * @return Collection |
||
| 76 | */ |
||
| 77 | abstract public function supportedMimetypes(): Collection; |
||
| 78 | } |
||
| 79 |
In the issue above, the returned value is violating the contract defined by the mentioned interface.
Let's take a look at an example: