| 1 | <?php |
||
| 8 | class ImageRatio extends AbstractRule |
||
| 9 | { |
||
| 10 | // the image width/height ration; |
||
| 11 | // can be a number or a string like 4:3, 16:9 |
||
| 12 | const OPTION_RATIO = 'ratio'; |
||
| 13 | // how much can the image ratio diverge from the allowed ratio |
||
| 14 | const OPTION_ERROR_MARGIN = 'error_margin'; |
||
| 15 | |||
| 16 | const MESSAGE = 'The image does must have a ratio (width/height) of {ratio})'; |
||
| 17 | |||
| 18 | const LABELED_MESSAGE = '{label} does must have a ratio (width/height) of {ratio})'; |
||
| 19 | |||
| 20 | protected $options = [ |
||
| 21 | self::OPTION_RATIO => 0, |
||
| 22 | self::OPTION_ERROR_MARGIN => 0, |
||
| 23 | ]; |
||
| 24 | |||
| 25 | 8 | public function validate($value, string $valueIdentifier = null) |
|
| 49 | } |
||
| 50 |