<?php
namespace App\Utils\BaseParser\TextParser\Types; class ContainerConditionalParse extends \App\Utils\BaseParser\TextParser\BlockRegexpAbstract { protected $matcher = null; public function __construct($options = [], $parent = null) { parent::__construct($options, $parent); if(!$this->options['isValid']) { throw new \Exception("isValid is not defined"); } } public function isValid() { \Engine\Debug\ParserCallTrace\ParserCallTrace::getInstance()->logCallStart($this, __METHOD__, func_get_args()); \Engine\Debug\ParserCallTrace\ParserCallTrace::getInstance()->logInput([ 'key' => $this->options['key'], 'rawData' => $this->rawData, ]); \Engine\Debug\ParserCallTrace\ParserCallTrace::getInstance()->logInput([ 'extractRegexp' => $this->extractRegexp, ], 'regexp'); if (is_string($this->options['isValid'])) { $condition = $this->options['isValid']; $ret = eval($condition); } else { $condition = $this->options['isValid']; $ret = $condition(); } \Engine\Debug\ParserCallTrace\ParserCallTrace::getInstance()->logOutput([ 'return' => $ret, ]); \Engine\Debug\ParserCallTrace\ParserCallTrace::getInstance()->logCallEnd(); return $ret; } protected function _extract(\App\Utils\BaseParser\TextParser\ExtractedBlock $ret, $originalRawData) { if (is_string($this->options['isValid'])) { $extract = $this->options['extract']; $ret = eval($extract); } else { $condition = $this->options['extract']; $ret = $condition($ret, $originalRawData); } return $ret; } } 