public function get() { if (!isset($this->subject, $this->operands, $this->then) || empty($this->operands)) { return null; } $operands = $this->operands; $this->template->addMultiPlaceholders($this->template->findPlaceholders($this->addPlaceholders)); $paramsTpl = ['subject' => $this->subject, 'params' => $operands, 'then' => $this->then, 'template' => $this->template]; if (isset($this->else)) { $paramsTpl['else'] = $this->else; } $data = []; $this->subject = strip_tags($this->subject); foreach ($operands as $keyParam => $valueParam) { $valueParam = Helper::toType($valueParam); if (is_string($valueParam)) { $valueParam = addslashes($valueParam); } $data[$keyParam] = $valueParam; } $value = ' $template = $params[\'template\']; if (' . preg_replace('/:([\\w]+)/', '$data[\'$1\']', $this->subject) . ') { return $template->replace($params[\'then\']); }' . (isset($this->else) ? ' else {return $template->replace($params[\'else\']);}' : null); return $this->execute->get(StringHelper::removeSpaces($value), $paramsTpl, $data); }
public function get() { if (!isset($this->subject) || empty($this->operands)) { return null; } $data = []; $this->subject = strip_tags($this->subject); foreach ($this->operands as $keyParam => $valueParam) { $valueParam = Helper::toType($valueParam); if (is_string($valueParam)) { $valueParam = addslashes($valueParam); } $data[$keyParam] = $valueParam; } return $this->execute->get(StringHelper::removeSpaces('return ' . preg_replace('/:([\\w]+)/', '$data[\'$1\']', $this->subject) . ';'), ['subject' => $this->subject, 'operands' => $this->operands], $data); }