sourceType === '' || $this->identity === '' || $this->signature === '') { throw new InvalidArgumentException('Preview sources require a type, identity, and content signature'); } if ($this->size !== null && $this->size < 0) { throw new InvalidArgumentException('Preview source size cannot be negative'); } if ($this->selector === '') { throw new InvalidArgumentException('Preview source selectors must be null or non-empty'); } $this->mimeType = MimeType::normalize($mimeType); } public function open(): BinaryResource { $resource = ($this->resourceFactory)(); if (!$resource instanceof BinaryResource) { throw new PreviewException('Preview source factory did not return a BinaryResource'); } return $resource; } }