@andreychuk this needs to look like (this)[https://github.com/purekid/mongodm/blob/master/src/Purekid/Mongodm/MongoDB.php#L454] and (this)[https://github.com/purekid/mongodm/blob/master/src/Purekid/Mongodm/MongoDB.php#L717].

**Also** this is incomplete see the (man)[http://us1.php.net/manual/en/mongocollection.aggregate.php] 

> #### Description
> `public array MongoCollection::aggregate ( array $pipeline [, array $op [, array $... ]] )`
> The MongoDB » aggregation framework provides a means to calculate aggregated values without having to use MapReduce. While MapReduce is powerful, it is often more difficult than necessary for many simple aggregation tasks, such as totaling or averaging field values.
> 
> This method accepts either a variable amount of pipeline operators, or a single array of operators constituting the pipeline.
> #### Parameters
> * __pipeline__
>   * An array of pipeline operators, or just the first operator.
> * __op__
>   * The second pipeline operator.
> * __...__
>   * Additional pipeline operators.

So it should be something more like

```php
    $ops = func_get_args();
    $collection_name = array_shift($opts);
    $query = array_shift($opts);
    return $this->_call(
        'aggregate', array(
            'collection_name' => $collection_name,
            'query'            => $query,
            'ops'         => $ops
        )
    );
```

With the matching 

```php
    case 'group':
        $args = array($query);
        $args = array_merge($args, $ops);
        $r = call_user_func_array(array($c, 'aggregate'), $args);
        break;
```