public function parse()
{
if (!$this->parsed) {
foreach ($this->patterns as $name => $pattern) {
if (preg_match($pattern, $this->text, $matches) !== 1) {
continue;
}
$this->type = $name;
$fname = 'parseMatches' . ucfirst($name);
$this->details = $this->{$fname}($matches);
break;
}
if ($this->details === null) {
$this->details = $this->parseFailure($matches);
}
$this->parsed = true;
}
return $this;
}