/** * Constructor. * * @param string $field * @param string $operator * @param string $value * * @throws InvalidQueryOperatorException */ public function __construct($field, $operator, $value) { // We'll escape the field to avoid allowing unsafe characters inside. $this->field = Utilities::escape($field, null, 3); // Validate and retrieve the operator. $this->operator = $this->validateOperator($operator); // Completely escape the value. $this->value = Utilities::escape($value); }
/** * Assembles an RDN with the specified attribute and value. * * @param string $attribute * @param array $values * * @return null|string */ protected function assembleRdns($attribute, array $values = []) { if (count($values) > 0) { $values = array_reverse($values); $values = array_map(function ($value) use($attribute) { return sprintf('%s=%s', $attribute, Utilities::escape($value, '', 2)); }, $values); return implode(',', $values); } return; }
/** * Adds a binding to the query. * * @param string $field * @param string $operator * @param string $value * @param string $type * * @throws InvalidQueryOperatorException * * @return Builder */ public function addBinding($field, $operator, $value, $type = 'where') { if (!array_key_exists($type, $this->bindings)) { throw new InvalidArgumentException("Invalid binding type: {$type}."); } $operator = $this->getOperator($operator); $value = Utilities::escape($value); $this->{$this->bindings[$type]}[] = compact('field', 'operator', 'value'); return $this; }
/** * Assembles an RDN with the specified attribute and value. * * @param string $attribute * @param array $values * * @return string */ protected function assembleRdns($attribute, array $values = []) { return implode(',', array_map(function ($value) use($attribute) { return sprintf('%s=%s', $attribute, Utilities::escape($value, '', 2)); }, $values)); }