Client   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 14
dl 0
loc 55
ccs 13
cts 13
cp 1
rs 10
c 1
b 0
f 1
wmc 3

3 Methods

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