app\models\Event::parse PHP Method

parse() public method

public parse ( )
    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;
    }

Usage Example

Example #1
0
 public function transform(Event $event)
 {
     $event->parse();
     return array_merge(['id' => $event->event_id, 'createdAt' => $event->date->toIso8601String(), 'type' => $event->type], $event->details);
 }
All Usage Examples Of app\models\Event::parse