content === '') { throw new \DomainException('Raw picture content cannot be empty.'); } if (strlen($this->content) > self::MAX_SIZE_IN_BYTES) { throw new \DomainException('Raw picture exceeds the maximum allowed size.'); } $trimmedName = mb_trim($this->originalName); if ($trimmedName === '') { throw new \DomainException('Raw picture original name cannot be empty.'); } $extension = mb_strtolower(pathinfo($trimmedName, PATHINFO_EXTENSION)); if (! in_array($extension, self::ALLOWED_EXTENSIONS, true)) { throw new \DomainException( 'Raw picture must have one of these extensions: ' . implode(', ', self::ALLOWED_EXTENSIONS) ); } } }