public static function getType(IRI $coid) {
    if ($coid->getScheme()!='coid' || $coid->getHost()==''
        || preg_match(self::REGEX_HOSTNAME, $coid->getHost()) != 1)
      return self::COID_INVALID;

    if ($coid->getPath()=='' || $coid->getPath()=='/')
      return self::COID_ROOT;

    $segments = explode('/', $coid->getPath());
    switch (count($segments)) {
      case 2:
        return (preg_match(self::REGEX_SEGMENT, $segments[1]) == 1)
          ? self::COID_UNVERSIONED
          : self::COID_INVALID;
      case 3:
        if (preg_match(self::REGEX_SEGMENT, $segments[1]) != 1)
          return self::COID_INVALID;

        if (preg_match(self::REGEX_SEGMENT, $segments[2]) == 1)
          return self::COID_VERSIONED;
        else
        if (preg_match(self::REGEX_VERSION_WILDCARD, $segments[2]) == 1)
          return self::COID_VERSION_WILDCARD;
        else
          return self::COID_INVALID;
      default:
        return self::COID_INVALID;
    }
  }