public static function checksum(
        $filePath,
        Key $key = null,
        $encoding = Halite::ENCODE_BASE64URLSAFE
    ): string {
        if ($filePath instanceof ReadOnlyFile) {
            $pos = $filePath->getPos();
            $filePath->reset(0);
            $checksum = self::checksumData(
                $filePath,
                $key,
                $encoding
            );
            $filePath->reset($pos);
            return $checksum;
        }

        if (\is_resource($filePath) || \is_string($filePath)) {
            $readOnly = new ReadOnlyFile($filePath);
            try {
                $checksum = self::checksumData(
                    $readOnly,
                    $key,
                    $encoding
                );
                return $checksum;
            } finally {
                if (isset($readOnly)) {
                    $readOnly->close();
                }
            }
        }
        throw new InvalidType(
            'Argument 1: Expected a filename or resource'
        );
    }