function Rectangle::__construct

Same name in other branches
  1. 9 core/lib/Drupal/Component/Utility/Rectangle.php \Drupal\Component\Utility\Rectangle::__construct()
  2. 8.9.x core/lib/Drupal/Component/Utility/Rectangle.php \Drupal\Component\Utility\Rectangle::__construct()
  3. 11.x core/lib/Drupal/Component/Utility/Rectangle.php \Drupal\Component\Utility\Rectangle::__construct()

Constructs a new Rectangle object.

Parameters

int $width: The width of the rectangle.

int $height: The height of the rectangle.

File

core/lib/Drupal/Component/Utility/Rectangle.php, line 63

Class

Rectangle
Rectangle rotation algebra class.

Namespace

Drupal\Component\Utility

Code

public function __construct($width, $height) {
    if ($width > 0 && $height > 0) {
        $this->width = $width;
        $this->height = $height;
        $this->boundingWidth = $width;
        $this->boundingHeight = $height;
    }
    else {
        throw new \InvalidArgumentException("Invalid dimensions ({$width}x{$height}) specified for a Rectangle object");
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.