public function mapReduce(
            $map, $reduce, array $out, array $query = array(),
            array $command = array(), $options = array())
    {
        $command = array_merge($command, array(
            'mapreduce' => $this->getCollectionName(),
            'map'       => is_string($map) ? new \MongoCode($map) : $map,
            'reduce'    => is_string($reduce) ? new \MongoCode($reduce) : $reduce,
            'out'       => $out,
            'query'     => $query,
        ));

        $result = $this->command($command, $options);

        if (isset($out['inline']) && $out['inline']) {
            return $result['results'];
        }

        return $this->getConnection()->getMongoDB()->selectCollection($result['result'])->find();
    }