LdapTools\Query\OperatorCollection::add PHP Method

add() public method

Add an Operator to the collection.
public add ( variadic $operators )
$operators variadic
    public function add(BaseOperator ...$operators)
    {
        foreach ($operators as $operator) {
            if ($operator instanceof bAnd) {
                $this->operators['and'][] = $operator;
            } elseif ($operator instanceof bOr) {
                $this->operators['or'][] = $operator;
            } elseif ($operator instanceof bNot) {
                $this->operators['not'][] = $operator;
            } elseif ($operator instanceof Wildcard) {
                $this->operators['wildcard'][] = $operator;
            } elseif ($operator instanceof MatchingRule) {
                $this->operators['matchingrule'][] = $operator;
            } elseif ($operator instanceof Comparison) {
                $this->operators['comparison'][] = $operator;
            } else {
                throw new InvalidArgumentException('Unknown operator type.');
            }
        }
        return $this;
    }

Usage Example

 function it_should_clone_the_operator_collection()
 {
     $operator = new Comparison('foo', Comparison::EQ, 'bar');
     $operators = new OperatorCollection();
     $operators->add($operator);
     $operation = new QueryOperation($operators);
     $new = clone $operation;
     $operator->setAttribute('foobar');
     $this->setFilter($new->getFilter());
     $this->getFilter()->toLdapFilter()->shouldNotBeEqualTo('(foobar=bar)');
 }
All Usage Examples Of LdapTools\Query\OperatorCollection::add