Test Failed
Pull Request — master (#77)
by
unknown
04:49
created

MongoClient::executeQuery()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 6
rs 9.4285
cc 1
eloc 3
nc 1
nop 3
1
<?php
2
3
/**
4
 * MongoClient.php
5
 *
6
 * @author Dennis de Greef <[email protected]>
7
 */
8
namespace Link0\Profiler\PersistenceHandler\MongoDbHandler;
9
10
/**
11
 * Extension of the MongoClient class to adhere to the interface we want to talk to
12
 *
13
 * @package Link0\Profiler\PersistenceHandler\MongoDbHandler
14
 */
15
final class MongoClient implements MongoClientInterface
16
{
17
    /**
18
     * @var \MongoDB\Driver\Manager
19
     */
20
    private $driverManager;
21
22
    public function __construct($uri = 'mongodb://127.0.0.1', $uriOptions = [], $driverOptions = [])
23
    {
24
        $this->driverManager = new \MongoDB\Driver\Manager($uri, $uriOptions, $driverOptions);
25
    }
26
27
28
    /**
29
     * @param string $namespace
30
     * @param array|object $filter
31
     * @param array $queryOptions
32
     * @return string[]
33
     *
34
     * @throws \MongoDB\Driver\Exception\Exception
35
     * @throws \MongoDB\Driver\Exception\AuthenticationException if authentication is needed and fails
36
     * @throws \MongoDB\Driver\Exception\ConnectionException if connection to the server fails for other then authentication reasons
37
     * @throws \MongoDB\Driver\Exception\RuntimeException on other errors (invalid command, command arguments, ...)
38
     */
39
    public function executeQuery($namespace, $filter, $queryOptions = array())
40
    {
41
        $query = new \MongoDB\Driver\Query($filter, $queryOptions);
42
43
        return iterator_to_array($this->driverManager->executeQuery($namespace, $query));
44
    }
45
}
46