density; } public function setDensity(float $density): static { $this->density = $density; return $this; } public function getReferenceWidth(): ?int { return $this->referenceWidth; } /** * The absolute $referenceWidth will be used as "1x" width. */ public function setReferenceWidth(int $referenceWidth): static { $this->referenceWidth = $referenceWidth; return $this; } public function getDescriptor(): string { return $this->density . static::DENSITY_UNIT; } public function getCalculatedWidth(): int { if ($this->referenceWidth === null) { throw new \InvalidArgumentException(sprintf( 'Reference width needs to be specified if pixel density descriptors (e. g. 2x) are used in srcset: %s', $this->getDescriptor() ), 1697743145); } return (int)($this->density * $this->referenceWidth); } }