public static function verify(
        $filename,
        SignaturePublicKey $publicKey,
        string $signature,
        $encoding = Halite::ENCODE_BASE64URLSAFE
    ): bool {
        if ($filename instanceof ReadOnlyFile) {
            $pos = $filename->getPos();
            $filename->reset(0);
            $verified = self::verifyData(
                $filename,
                $publicKey,
                $signature,
                $encoding
            );
            $filename->reset($pos);
            return $verified;
        }
        if (\is_resource($filename) || \is_string($filename)) {
            $readOnly = new ReadOnlyFile($filename);
            try {
                $verified = self::verifyData(
                    $readOnly,
                    $publicKey,
                    $signature,
                    $encoding
                );
                return $verified;
            } finally {
                if (isset($readOnly)) {
                    $readOnly->close();
                }
            }
        }
        throw new InvalidType(
            'Argument 1: Expected a filename or resource'
        );
    }