self::streamFromFilePath($input), is_string($input) => self::streamFromData($input), self::isStream($input) => $input, default => throw new InvalidArgumentException( 'Decoder input must be either file path, stream resource or binary data' ) }; $result = rewind($stream); if ($result === false) { throw new StreamException('Failed to rewind stream'); } return GifDataStream::decode($stream); } /** * Determine if input is stream resource. */ private static function isStream(mixed $input): bool { return is_resource($input) && get_resource_type($input) === 'stream'; } }