class Box implements BoxInterface

A box implementation.

Methods

__construct(int $width, int $height)

Constructs the Size with given width and height.

int
getWidth()

Gets box width.

int
getHeight()

Gets box height.

scale(float $ratio)

Creates new BoxInterface instance with ratios applied to both sides.

increase(int $size)

Creates new BoxInterface, adding given size to both sides.

bool
contains(BoxInterface $box, PointInterface $start = null)

Checks whether current box can fit given box at a given start position, start position defaults to top left corner xy(0,0).

int
square()

Gets current box square, useful for getting total number of pixels in a given box.

string
__toString()

Returns a string representation of the current box.

widen(int $width)

Resizes box to given width, constraining proportions and returns the new box.

heighten(int $height)

Resizes box to given height, constraining proportions and returns the new box.

Details

at line 39
__construct(int $width, int $height)

Constructs the Size with given width and height.

Parameters

int $width
int $height

Exceptions

InvalidArgumentException

at line 59
int getWidth()

Gets box width.

Return Value

int

See also

BoxInterface::getWidth

at line 69
int getHeight()

Gets box height.

Return Value

int

See also

BoxInterface::getHeight

at line 79
BoxInterface scale(float $ratio)

Creates new BoxInterface instance with ratios applied to both sides.

Parameters

float $ratio

Return Value

BoxInterface

See also

BoxInterface::scale

at line 92
BoxInterface increase(int $size)

Creates new BoxInterface, adding given size to both sides.

Parameters

int $size

Return Value

BoxInterface

See also

BoxInterface::increase

at line 102
bool contains(BoxInterface $box, PointInterface $start = null)

Checks whether current box can fit given box at a given start position, start position defaults to top left corner xy(0,0).

Parameters

BoxInterface $box
PointInterface $start

Return Value

bool

See also

BoxInterface::contains

at line 114
int square()

Gets current box square, useful for getting total number of pixels in a given box.

Return Value

int

See also

BoxInterface::square

at line 124
string __toString()

Returns a string representation of the current box.

Return Value

string

See also

BoxInterface::__toString

at line 134
BoxInterface widen(int $width)

Resizes box to given width, constraining proportions and returns the new box.

Parameters

int $width

Return Value

BoxInterface

See also

BoxInterface::widen

at line 144
BoxInterface heighten(int $height)

Resizes box to given height, constraining proportions and returns the new box.

Parameters

int $height

Return Value

BoxInterface

See also

BoxInterface::heighten