*/ private readonly int $width, /** * @var int<0, max> */ private readonly int $height, private readonly ?ImageInfo $imageInfo = null ) {} public function isFile(): bool { return $this->getImageInfoObject()->isFile(); } public function getRealPath(): string { return $this->getImageInfoObject()->getRealPath(); } /** * @return int<0, max> */ public function getWidth(): int { return $this->width; } /** * @return int<0, max> */ public function getHeight(): int { return $this->height; } public function getExtension(): string { return $this->getImageInfoObject()->getExtension(); } public static function createFromImageInfo(ImageInfo $imageInfo): self { return new self($imageInfo->getRealPath(), $imageInfo->getWidth(), $imageInfo->getHeight(), $imageInfo); } /** * @return array{0: int<0, max>, 1: int<0, max>, 2: string, 3: string} */ public function toLegacyArray(): array { return [ 0 => $this->width, 1 => $this->height, 2 => $this->getExtension(), 3 => $this->filePath, ]; } private function getImageInfoObject(): ImageInfo { return !$this->imageInfo instanceof ImageInfo ? GeneralUtility::makeInstance(ImageInfo::class, $this->filePath) : $this->imageInfo; } }