You are here

protected function Resource::setDimensions in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/media/src/OEmbed/Resource.php \Drupal\media\OEmbed\Resource::setDimensions()
  2. 9 core/modules/media/src/OEmbed/Resource.php \Drupal\media\OEmbed\Resource::setDimensions()

Sets the dimensions.

Parameters

int|null $width: The width of the resource.

int|null $height: The height of the resource.

Throws

\InvalidArgumentException If either $width or $height are not numbers greater than zero.

File

core/modules/media/src/OEmbed/Resource.php, line 521

Class

Resource
Value object representing an oEmbed resource.

Namespace

Drupal\media\OEmbed

Code

protected function setDimensions($width, $height) {
  if (isset($width) && $width <= 0 || isset($height) && $height <= 0) {
    throw new \InvalidArgumentException('The dimensions must be NULL or numbers greater than zero.');
  }
  $this->width = isset($width) ? (int) $width : NULL;
  $this->height = isset($height) ? (int) $height : NULL;
}