0 follower

Final Class Yiisoft\Validator\Rule\Image\ImageAspectRatio

InheritanceYiisoft\Validator\Rule\Image\ImageAspectRatio

Method Details

Hide inherited methods

__construct() public method

public mixed __construct ( integer $width, integer $height, float $margin 0 )
$width integer

Expected width part for aspect ratio. For example, for 4:3 aspect ratio, it will be 4.

$height integer

Expected height part for aspect ratio. For example, for 4:3 aspect ratio, it will be 3.

$margin float

Expected margin for aspect ratio in percents. For example, with value 1 and 4:3 aspect ratio:

  • If the validated image has height of 600 pixels, the allowed width range is 794 - 806 pixels.
  • If the validated image has width of 800 pixels, the allowed height range is 596 - 604 pixels.

Defaults to 0 meaning no margin is allowed. For example, image with size 800 x 600 pixels and aspect ratio expected to be 4:3 will meet this requirement.

                public function __construct(
    private readonly int $width,
    private readonly int $height,
    private readonly float $margin = 0,
) {}

            
getHeight() public method

public integer getHeight ( )

                public function getHeight(): int
{
    return $this->height;
}

            
getMargin() public method

public float getMargin ( )

                public function getMargin(): float
{
    return $this->margin;
}

            
getWidth() public method

public integer getWidth ( )

                public function getWidth(): int
{
    return $this->width;
}