Skip to content
This repository has been archived by the owner on Nov 11, 2020. It is now read-only.

Commit

Permalink
Add support for new bits operators
Browse files Browse the repository at this point in the history
  • Loading branch information
alcaeus committed Jan 5, 2016
1 parent 7a74690 commit dfc708c
Show file tree
Hide file tree
Showing 3 changed files with 125 additions and 1 deletion.
60 changes: 60 additions & 0 deletions lib/Doctrine/MongoDB/Query/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,66 @@ public function bitOr($value)
return $this;
}

/**
* Matches documents where all of the bit positions given by the query are
* clear.
*
* @see Expr::bitsAllClear()
* @see https://docs.mongodb.org/manual/reference/operator/query/bitsAllClear/
* @param int|array|\MongoBinData $value
* @return self
*/
public function bitsAllClear($value)
{
$this->expr->bitsAllClear($value);
return $this;
}

/**
* Matches documents where all of the bit positions given by the query are
* set.
*
* @see Expr::bitsAllSet()
* @see https://docs.mongodb.org/manual/reference/operator/query/bitsAllSet/
* @param int|array|\MongoBinData $value
* @return self
*/
public function bitsAllSet($value)
{
$this->expr->bitsAllSet($value);
return $this;
}

/**
* Matches documents where any of the bit positions given by the query are
* clear.
*
* @see Expr::bitsAnyClear()
* @see https://docs.mongodb.org/manual/reference/operator/query/bitsAnyClear/
* @param int|array|\MongoBinData $value
* @return self
*/
public function bitsAnyClear($value)
{
$this->expr->bitsAnyClear($value);
return $this;
}

/**
* Matches documents where any of the bit positions given by the query are
* set.
*
* @see Expr::bitsAnySet()
* @see https://docs.mongodb.org/manual/reference/operator/query/bitsAnySet/
* @param int|array|\MongoBinData $value
* @return self
*/
public function bitsAnySet($value)
{
$this->expr->bitsAnySet($value);
return $this;
}

/**
* Apply a bitwise xor operation on the current field.
*
Expand Down
60 changes: 60 additions & 0 deletions lib/Doctrine/MongoDB/Query/Expr.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,66 @@ public function bitOr($value)
return $this->bit('or', $value);
}

/**
* Matches documents where all of the bit positions given by the query are
* clear.
*
* @see Builder::bitsAllClear()
* @see https://docs.mongodb.org/manual/reference/operator/query/bitsAllClear/
* @param int|array|\MongoBinData $value
* @return self
*/
public function bitsAllClear($value)
{
$this->requiresCurrentField();
return $this->operator('$bitsAllClear', $value);
}

/**
* Matches documents where all of the bit positions given by the query are
* set.
*
* @see Builder::bitsAllSet()
* @see https://docs.mongodb.org/manual/reference/operator/query/bitsAllSet/
* @param int|array|\MongoBinData $value
* @return self
*/
public function bitsAllSet($value)
{
$this->requiresCurrentField();
return $this->operator('$bitsAllSet', $value);
}

/**
* Matches documents where any of the bit positions given by the query are
* clear.
*
* @see Builder::bitsAnyClear()
* @see https://docs.mongodb.org/manual/reference/operator/query/bitsAnyClear/
* @param int|array|\MongoBinData $value
* @return self
*/
public function bitsAnyClear($value)
{
$this->requiresCurrentField();
return $this->operator('$bitsAnyClear', $value);
}

/**
* Matches documents where any of the bit positions given by the query are
* set.
*
* @see Builder::bitsAnySet()
* @see https://docs.mongodb.org/manual/reference/operator/query/bitsAnySet/
* @param int|array|\MongoBinData $value
* @return self
*/
public function bitsAnySet($value)
{
$this->requiresCurrentField();
return $this->operator('$bitsAnySet', $value);
}

/**
* Apply a bitwise xor operation on the current field.
*
Expand Down
6 changes: 5 additions & 1 deletion tests/Doctrine/MongoDB/Tests/Query/BuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,11 @@ public function provideProxiedExprMethods()
'text()' => array('text', array('foo')),
'max()' => array('max', array(1)),
'min()' => array('min', array(1)),
'comment()' => array('comment', array('A comment explaining what the query does'))
'comment()' => array('comment', array('A comment explaining what the query does')),
'bitsAllClear()' => array('bitsAllClear', array(5)),
'bitsAllSet()' => array('bitsAllSet', array(5)),
'bitsAnyClear()' => array('bitsAnyClear', array(5)),
'bitsAnySet()' => array('bitsAnySet', array(5)),
);
}

Expand Down

0 comments on commit dfc708c

Please sign in to comment.