Completed
Pull Request — master (#8)
by Alessandro
02:58
created

Client   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 3
Bugs 1 Features 2
Metric Value
wmc 3
c 3
b 1
f 2
lcom 0
cbo 3
dl 0
loc 44
ccs 12
cts 12
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A selectDatabase() 0 9 1
A selectCollection() 0 9 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Facile\MongoDbBundle\Capsule;
6
7
use Facile\MongoDbBundle\Services\Loggers\DataCollectorLoggerInterface;
8
use MongoDB\Client as MongoClient;
9
10
/**
11
 * Class Client.
12
 */
13
final class Client extends MongoClient
14
{
15
    /** @var DataCollectorLoggerInterface */
16
    private $logger;
17
18
    /**
19
     * Client constructor.
20
     *
21
     * @param string                       $uri
22
     * @param array                        $uriOptions
23
     * @param array                        $driverOptions
24
     * @param DataCollectorLoggerInterface $logger
25
     */
26 3
    public function __construct($uri = 'mongodb://localhost:27017', array $uriOptions = [], array $driverOptions = [], DataCollectorLoggerInterface $logger)
27
    {
28 3
        parent::__construct($uri, $uriOptions, $driverOptions);
29 3
        $this->logger = $logger;
30 3
    }
31
    /**
32
     * {@inheritdoc}
33
     */
34 3
    public function selectDatabase($databaseName, array $options = [])
35
    {
36 3
        $debug = $this->__debugInfo();
37
        $options += [
38 3
            'typeMap' => $debug['typeMap'],
39
        ];
40
41 3
        return new Database($debug['manager'], $databaseName, $options, $this->logger);
42
    }
43
44
    /**
45
     * {@inheritdoc}
46
     */
47 1
    public function selectCollection($databaseName, $collectionName, array $options = [])
48
    {
49 1
        $debug = $this->__debugInfo();
50
        $options += [
51 1
            'typeMap' => $debug['typeMap'],
52
        ];
53
54 1
        return new Collection($debug['manager'], $databaseName, $collectionName, $options, $this->logger);
55
    }
56
}
57