public static function consume()

in src/inlines/AutoLink.php [43:80]


  public static function consume(
    Context $context,
    string $string,
    int $offset,
  ): ?(Inline, int) {
    if ($string[$offset] !== '<') {
      return null;
    }
    $start = $offset + 1;

    $end = Str\search($string, '>', $offset);
    if ($end === null) {
      return null;
    }
    $offset = $end + 1;

    $uri = Str\slice($string, $start, $end - $start);
    if (\preg_match(self::ABSOLUTE_URI_PATTERN, $uri) === 1) {
      if (!$context->areAllURISchemesEnabled()) {
        $allowed_uri_schemes = $context->getAllowedURISchemes();
        if (!C\any($allowed_uri_schemes, $elem ==> Str\starts_with_ci($uri, $elem.':'))) {
          return null;
        }
      }
      return tuple(new self($uri, $uri), $offset);
    }

    if (\preg_match(self::EMAIL_ADDRESS_PATTERN, $uri) === 1) {
      if (
        $context->areAllURISchemesEnabled() ||
        C\contains_key($context->getAllowedURISchemes(), 'mailto')
      ) {
        return tuple(new self($uri, 'mailto:'.$uri), $offset);
      }
    }

    return null;
  }