/** * Applies the output filter and returns the resultting value * * @return mixed The filtered value */ public function getForOutput() { // Only apply the filter if there is one if ($this->outFilter instanceof \r8\iface\Filter) { return $this->outFilter->filter($this->getValue()); } else { return $this->getValue(); } }
/** * Parses a query string into an array * * @param String $query The query string to parser * @return Array Returns the parsed string as an array */ public function parse($query) { $query = (string) $query; // Grab everything after the starting delimiter if (\r8\str\contains($this->startDelim, $query)) { $query = substr($query, strpos($query, $this->startDelim) + 1); } // Cut off everything after the ending delimiter if (\r8\str\contains($this->endDelim, $query)) { $query = substr($query, 0, strpos($query, $this->endDelim)); } // Split the query into its pairs $query = explode($this->outerDelim, $query); $result = array(); // Loop through each pair foreach ($query as $pair) { // Skip over empty pairs if (\r8\isEmpty($pair)) { continue; } // split the pair up into its key and value if (\r8\str\contains($this->innerDelim, $pair)) { list($key, $value) = explode($this->innerDelim, $pair, 2); } else { list($key, $value) = array($pair, ""); } // if the key is empty, do nothing with it if (\r8\isEmpty($key, \r8\ALLOW_SPACES)) { continue; } // Apply the filters to the key and value $key = $this->keyFilter->filter($key); $value = $this->valueFilter->filter($value); // parse the list of keys into an array $key = $this->parseKey($key); // Add the branch to the result array \r8\ary\branch($result, $value, $key); } return $result; }
/** * Applies a filter to the selected sections * * @param Object $filter The filter to apply * @return Object Returns a self reference */ public function filter(\r8\iface\Filter $filter) { if (!$this->quoted && !$this->unquoted) { return $this; } foreach ($this->sections as $section) { if ($section->isQuoted() && $this->quoted || !$section->isQuoted() && $this->unquoted) { $section->setContent($filter->filter($section->getContent())); } } return $this; }
/** * Returns the current value of the iterator * * @return mixed */ public function current() { return $this->filter->filter(parent::current()); }