src/Query/Compound/BoolQuery.php
public function add(BuilderInterface $query, $type = self::MUST, $key = null)
    {
        if (!in_array($type, [self::MUST, self::MUST_NOT, self::SHOULD, self::FILTER])) {
            throw new \UnexpectedValueException(sprintf('The bool operator %s is not supported', $type));
        }

        if (!$key) {
            $key = bin2hex(random_bytes(30));
        }

        $this->container[$type][$key] = $query;

        return $key;
    }
public function add(BuilderInterface $query, $type = self::MUST, $key = null)
    {
        if (!in_array($type, [self::MUST, self::MUST_NOT, self::SHOULD, self::FILTER])) {
            throw new \UnexpectedValueException(sprintf('The bool operator %s is not supported', $type));
        }

        if (!$key) {
            $key = bin2hex(random_bytes(30));
        }

        $this->container[$type][$key] = $query;

        return $key;
    }
public function add ( BuilderInterface $ query , $ type = self :: MUST , $ key = null ) { if ( ! in_array ( $ type , [ self :: MUST , self :: MUST_NOT , self :: SHOULD , self :: FILTER ] ) ) { throw new \ UnexpectedValueException ( sprintf ( 'The bool operator %s is not supported' , $ type ) ) ; } if ( ! $ key ) { $ key = bin2hex ( random_bytes ( 30 ) ) ; } $ this -> container [ $ type ] [ $ key ] = $ query ; return $ key ; }
Add BuilderInterface object to bool operator.

@param BuilderInterface $query Query add to the bool.
@param string           $type  Bool type. Example: must, must_not, should.
@param string           $key   Key that indicates a builder id.

@return string Key of added builder.

@throws \UnexpectedValueException
Add BuilderInterface object to bool operator .