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

Commit

Permalink
Rename value() method to expression()
Browse files Browse the repository at this point in the history
  • Loading branch information
Andreas Braun committed Jul 24, 2015
1 parent ce86558 commit 57512f5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
29 changes: 15 additions & 14 deletions lib/Doctrine/MongoDB/Aggregation/Stage/Operator.php
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,21 @@ public function eq($expression1, $expression2)
return $this->operator('$eq', array($expression1, $expression2));
}

/**
* Used to use an expression as field value. Can be any expression
*
* @see http://docs.mongodb.org/manual/meta/aggregation-quick-reference/#aggregation-expressions
* @param mixed|Operator $value
* @return $this
*/
public function expression($value)
{
$this->requiresCurrentField();
$this->expr[$this->currentField] = $this->ensureArray($value);

return $this;
}

/**
* Set the current field for building the expression.
*
Expand Down Expand Up @@ -748,20 +763,6 @@ public function toUpper($expression)
return $this->operator('$toUpper', $expression);
}

/**
* Used to set a value directly. Similar to $literal, except that the pipeline will parse any expressions contained.
*
* @param mixed|Operator $value
* @return $this
*/
public function value($value)
{
$this->requiresCurrentField();
$this->expr[$this->currentField] = $this->ensureArray($value);

return $this;
}

/**
* Returns the week of the year for a date as a number between 0 and 53.
*
Expand Down
2 changes: 1 addition & 1 deletion tests/Doctrine/MongoDB/Tests/Aggregation/BuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public function testGetPipeline()
)
->group()
->field('_id')
->value('$user')
->expression('$user')
->field('numOrders')
->sum(1)
->field('totalAmount')
Expand Down

0 comments on commit 57512f5

Please sign in to comment.