Oihana PHP

Dimension

Defines the canonical keys of a two-dimensional size pair.

Using these constants instead of the raw 'width' / 'height' magic strings keeps producers and consumers of a dimension pair in sync — for instance the array{width:int,height:int} returned by aspectFit().

Tags
example
use oihana\core\maths\Dimension;
use function oihana\core\maths\aspectFit;

$size = aspectFit( 1920 , 1080 , targetWidth: 1280 ) ;

echo $size[ Dimension::WIDTH ]  ; // 1280
echo $size[ Dimension::HEIGHT ] ; // 720
author

Marc Alcaraz (ekameleon)

since
1.2.0

Table of Contents

Constants

HEIGHT  : string = 'height'
The vertical extent (height) key.
WIDTH  : string = 'width'
The horizontal extent (width) key.

Methods

all()  : array<string|int, string>
Returns the list of valid dimension keys.
isValid()  : bool
Checks if a given value is a valid dimension key.

Constants

HEIGHT

The vertical extent (height) key.

public string HEIGHT = 'height'

Type: string

WIDTH

The horizontal extent (width) key.

public string WIDTH = 'width'

Type: string

Methods

all()

Returns the list of valid dimension keys.

public static all() : array<string|int, string>
Return values
array<string|int, string>

isValid()

Checks if a given value is a valid dimension key.

public static isValid(string $value) : bool
Parameters
$value : string
Return values
bool
On this page

Search results