Completed
Pull Request — master (#8)
by Alessandro
03:33 queued 55s
created

Database::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 5
ccs 4
cts 4
cp 1
rs 9.4285
cc 1
eloc 3
nc 1
nop 4
crap 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\Database as MongoDatabase;
9
use MongoDB\Driver\Manager;
10
11
/**
12
 * Class Database.
13
 */
14
final class Database extends MongoDatabase
15
{
16
    /**
17
     * @var DataCollectorLoggerInterface
18
     */
19
    private $logger;
20
21
    /**
22
     * Database constructor.
23
     *
24
     * @param Manager                      $manager
25
     * @param string                       $databaseName
26
     * @param array                        $options
27
     * @param DataCollectorLoggerInterface $logger
28
     */
29 3
    public function __construct(Manager $manager, $databaseName, array $options = [], DataCollectorLoggerInterface $logger)
30
    {
31 3
        parent::__construct($manager, $databaseName, $options);
32 3
        $this->logger = $logger;
33 3
    }
34
35
    /**
36
     * {@inheritdoc}
37
     */
38
    public function selectCollection($collectionName, array $options = [])
39
    {
40
        $debug = $this->__debugInfo();
41
        $options += [
42
            'readConcern' => $debug['readConcern'],
43
            'readPreference' => $debug['readPreference'],
44
            'typeMap' => $debug['typeMap'],
45
            'writeConcern' => $debug['writeConcern'],
46
        ];
47
48
        return new Collection($debug['manager'], $debug['databaseName'], $collectionName, $options, $this->logger);
49
    }
50
}
51