/** * Adds name/value pair specifying a word phrase and property where it need to be searched. * * @param string $name The property name * @param string|SearchQuery $value The word phrase * @param int $match The match type. One of SearchQueryMatch::* values * @throws \InvalidArgumentException */ public function item($name, $value, $match = SearchQueryMatch::DEFAULT_MATCH) { if ($value instanceof SearchQuery && $value->isComplex() && $match != SearchQueryMatch::DEFAULT_MATCH) { throw new \InvalidArgumentException('The match argument can be specified only if the value argument is a string or a simple query.'); } if (!$this->searchStringManager->isAcceptableItem($name, $value, $match)) { throw new \InvalidArgumentException(sprintf('This combination of arguments are not valid. Name: %s. Value: %s. Match: %d.', $name, is_object($value) ? get_class($value) : $value, $match)); } $this->andOperatorIfNeeded(); $value = $value instanceof SearchQuery ? $value->getExpression() : $value; $this->expr->add(new SearchQueryExprItem($name, $value, $match)); }