Beispiel #1
0
 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);
 }
Beispiel #3
0
 private function _searchParamsByFilters(array $matches, array $array_recursive, $i)
 {
     // Parsing params of filter
     preg_match_all('/
             \\&
             (?P<names>\\w+)			    # name variable of filter
             \\s*\\=\\s*
             (?P<values>\\{{3}\\d+\\}{3})	# value variable of filter
             [^\\&]*
         /iux', $matches['value'][$i], $params);
     $j = 0;
     $result = [];
     if (isset($params['names'])) {
         foreach ($params['names'] as $name) {
             if (!isset($params['values'][$j]) || !isset($name)) {
                 continue;
             }
             $result[$name] = mb_substr($array_recursive[trim($params['values'][$j])], 2, -2, 'UTF-8');
             // Search prefix
             $result[$name] = $this->_searchPrefix($name, $result[$name]);
             if (is_string($result[$name])) {
                 $result[$name] = Helper::toType($result[$name]);
             }
             ++$j;
         }
     }
     return $result;
 }
Beispiel #4
0
 /**
  * @param mixed      $rows
  * @param ConnectionInterface $connection
  * @return array
  */
 public function typeCast($rows, ConnectionInterface $connection = null)
 {
     if (isset($connection)) {
         $this->setConnection($connection);
     }
     $connection = $this->getConnection();
     if ($connection->typeCast) {
         $rows = is_array($rows) ? ArrayHelper::toType($rows) : Helper::toType($rows);
     }
     return $rows;
 }
Beispiel #5
0
 /**
  * @inheritdoc
  */
 public function sanitize($input)
 {
     return Helper::toType($input);
 }
Beispiel #6
0
 /**
  * Conversion to type of array values.
  *
  * @param array $array current array
  * @param bool $recursive
  * @return array
  */
 public static function toType(array $array, $recursive = true)
 {
     return static::map($array, function ($value) {
         return Helper::toType($value);
     }, $recursive);
 }