protected function getTree(DateTimeParseContext $context) { // prepare parse tree $regionIds = ZoneRulesProvider::getAvailableZoneIds(); $regionIdsSize = count($regionIds); $cached = $context->isCaseSensitive() ? self::$cachedPrefixTree : self::$cachedPrefixTreeCI; if ($cached == null || $cached->getKey() != $regionIdsSize) { $cached = $context->isCaseSensitive() ? self::$cachedPrefixTree : self::$cachedPrefixTreeCI; if ($cached == null || $cached->getKey() != $regionIdsSize) { $cached = new SimpleImmutableEntry($regionIdsSize, PrefixTree::newTree($regionIds, $context)); if ($context->isCaseSensitive()) { self::$cachedPrefixTree = $cached; } else { self::$cachedPrefixTreeCI = $cached; } } } return $cached->getValue(); }
public function parse(DateTimeParseContext $context, $text, $position) { $length = strlen($text); if ($position === $length) { return ~$position; } if ($position < 0 || $position >= $length) { throw new \OutOfRangeException(); } $ch = $text[$position]; if ($ch !== $this->literal) { if ($context->isCaseSensitive() || strtoupper($ch) !== strtoupper($this->literal) && strtolower($ch) !== strtolower($this->literal)) { return ~$position; } } return $position + 1; }