public static function provideProxiedExprMethods() { $expression = new Expr(); $expression->field('dayOfMonth')->dayOfMonth('$dateField')->field('dayOfWeek')->dayOfWeek('$dateField'); return array('avg()' => array('avg', array('$field')), 'max()' => array('max', array('$field')), 'min()' => array('min', array('$field')), 'stdDevPop()' => array('stdDevPop', array('$field')), 'stdDevSamp()' => array('stdDevSamp', array('$field')), 'sum()' => array('sum', array('$field'))); }
/** * Set the current field for building the expression. * * @see Expr::field * @param string $fieldName * @return self */ public function field($fieldName) { $this->expr->field($fieldName); return $this; }
public function provideProxiedExprMethods() { $expression = new Expr(); $expression->field('dayOfMonth')->dayOfMonth('$dateField')->field('dayOfWeek')->dayOfWeek('$dateField'); return ['addToSet()' => ['addToSet', ['$field']], 'avg()' => ['avg', ['$field']], 'expression()' => ['expression', [$expression]], 'first()' => ['first', ['$field']], 'last()' => ['last', ['$field']], 'max()' => ['max', ['$field']], 'min()' => ['min', ['$field']], 'push()' => ['push', ['$field']], 'stdDevPop()' => ['stdDevPop', ['$field']], 'stdDevSamp()' => ['stdDevSamp', ['$field']], 'sum()' => ['sum', ['$field']]]; }
public function testLet() { $vars = new Expr(); $vars->field('total')->add('$price', '$tax')->field('discounted')->cond('$applyDiscount', 0.9, 1); $in = new Expr(); $in->multiply('$$total', '$$discounted'); $expr = new Expr(); $this->assertSame($expr, $expr->field('finalTotal')->let($vars, $in)); $this->assertSame(array('finalTotal' => array('$let' => array('vars' => array('total' => array('$add' => array('$price', '$tax')), 'discounted' => array('$cond' => array('if' => '$applyDiscount', 'then' => 0.9, 'else' => 1))), 'in' => array('$multiply' => array('$$total', '$$discounted'))))), $expr->getExpression()); }
/** * @param string $fieldName * @return self */ public function field($fieldName) { $fieldName = $this->getDocumentPersister()->prepareFieldName($fieldName); parent::field($fieldName); return $this; }
public function provideProxiedExprMethods() { $expression = new Expr(); $expression->field('dayOfMonth')->dayOfMonth('$dateField')->field('dayOfWeek')->dayOfWeek('$dateField'); return array('abs()' => array('abs', array('$number')), 'add()' => array('add', array(5, '$field', '$otherField')), 'allElementsTrue()' => array('allElementsTrue', array('$field')), 'anyElementTrue()' => array('anyElementTrue', array('$field')), 'arrayElemAt()' => array('arrayElemAt', array('$array', '$index')), 'ceil()' => array('ceil', array('$number')), 'cmp()' => array('cmp', array('$field', '$otherField')), 'concat()' => array('concat', array('foo', '$field', '$otherField')), 'concatArrays()' => array('concatArrays', array('$field', '$otherField')), 'cond()' => array('cond', array('$ifField', '$field', '$otherField')), 'dateToString()' => array('dateToString', array('%Y-%m-%d', '$dateField')), 'dayOfMonth()' => array('dayOfMonth', array('$dateField')), 'dayOfWeek()' => array('dayOfWeek', array('$dateField')), 'dayOfYear()' => array('dayOfYear', array('$dateField')), 'divide()' => array('divide', array('$field', 5)), 'eq()' => array('eq', array('$field', '$otherField')), 'exp()' => array('exp', array('$field')), 'expression()' => array('expression', array($expression)), 'filter()' => array('filter', array('$input', '$as', '$cond')), 'floor()' => array('floor', array('$number')), 'gt()' => array('gt', array('$field', '$otherField')), 'gte()' => array('gte', array('$field', '$otherField')), 'hour()' => array('hour', array('$dateField')), 'ifNull()' => array('ifNull', array('$field', '$otherField')), 'isArray()' => array('isArray', array('$field')), 'let()' => array('let', array('$vars', '$in')), 'literal()' => array('literal', array('$field')), 'ln()' => array('ln', array('$number')), 'log()' => array('log', array('$number', '$base')), 'log10()' => array('log10', array('$number')), 'lt()' => array('lt', array('$field', '$otherField')), 'lte()' => array('lte', array('$field', '$otherField')), 'map()' => array('map', array('$quizzes', 'grade', array('$add' => array('$$grade' => 2)))), 'meta()' => array('meta', array('textScore')), 'millisecond()' => array('millisecond', array('$dateField')), 'minute()' => array('minute', array('$dateField')), 'mod()' => array('mod', array('$field', 5)), 'month()' => array('month', array('$dateField')), 'multiply()' => array('multiply', array('$field', 5)), 'ne()' => array('ne', array('$field', '$otherField')), 'not()' => array('not', array('$field')), 'pow()' => array('pow', array('$number', '$exponent')), 'second()' => array('second', array('$dateField')), 'setDifference()' => array('setDifference', array('$field', '$otherField')), 'setEquals()' => array('setEquals', array('$field', '$otherField', '$anotherField')), 'setIntersection()' => array('setIntersection', array('$field', '$otherField', '$anotherField')), 'setIsSubset()' => array('setIsSubset', array('$field', '$otherField')), 'setUnion()' => array('setUnion', array('$field', '$otherField', '$anotherField')), 'size()' => array('size', array('$field')), 'slice()' => array('slice', array('$array', '$index')), 'sqrt()' => array('sqrt', array('$number')), 'strcasecmp()' => array('strcasecmp', array('$field', '$otherField')), 'substr()' => array('substr', array('$field', 0, '$length')), 'subtract()' => array('subtract', array('$field', 5)), 'toLower()' => array('toLower', array('$field')), 'toUpper()' => array('toUpper', array('$field')), 'trunc()' => array('trunc', array('$number')), 'week()' => array('week', array('$dateField')), 'year()' => array('year', array('$dateField'))); }
public function provideProxiedExprMethods() { $expression = new Expr(); $expression->field('dayOfMonth')->dayOfMonth('$dateField')->field('dayOfWeek')->dayOfWeek('$dateField'); return array('addToSet()' => array('addToSet', array('$field')), 'avg()' => array('avg', array('$field')), 'expression()' => array('expression', array($expression)), 'first()' => array('first', array('$field')), 'last()' => array('last', array('$field')), 'max()' => array('max', array('$field')), 'min()' => array('min', array('$field')), 'push()' => array('push', array('$field')), 'stdDevPop()' => array('stdDevPop', array('$field')), 'stdDevSamp()' => array('stdDevSamp', array('$field')), 'sum()' => array('sum', array('$field'))); }