| Total Complexity | 5 |
| Total Lines | 25 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 5 | class WidthBetweenRule extends MediaItemRule |
||
| 6 | { |
||
| 7 | public function __construct( |
||
| 8 | protected int $minWidth = 0, |
||
| 9 | protected int $maxWidth = 0 |
||
| 10 | ) { |
||
| 11 | } |
||
| 12 | |||
| 13 | public function validateMediaItem(): bool |
||
| 14 | { |
||
| 15 | if (! $media = $this->getTemporaryUploadMedia()) { |
||
| 16 | return true; |
||
| 17 | } |
||
| 18 | |||
| 19 | $size = getimagesize($media->getPath()); |
||
| 20 | $actualWidth = $size[0]; |
||
| 21 | |||
| 22 | return $actualWidth >= $this->minWidth && $actualWidth <= $this->maxWidth; |
||
| 23 | } |
||
| 24 | |||
| 25 | public function message() |
||
| 30 | ]); |
||
| 31 | } |
||
| 32 | } |
||
| 33 |