public function parse(DateTimeParseContext $context, $text, $position) { // simple looping parser to find the chronology if ($position < 0 || $position > strlen($text)) { throw new IndexOutOfBoundsException(); } $chronos = AbstractChronology::getAvailableChronologies(); $bestMatch = null; $matchLen = -1; foreach ($chronos as $chrono) { if ($this->textStyle === null) { $name = $chrono->getId(); } else { $name = $this->getChronologyName($chrono, $context->getLocale()); } $nameLen = strlen($name); if ($nameLen > $matchLen && $context->subSequenceEquals($text, $position, $name, 0, $nameLen)) { $bestMatch = $chrono; $matchLen = $nameLen; } } if ($bestMatch === null) { return ~$position; } $context->setParsed($bestMatch); return $position + $matchLen; }