Completed
Pull Request — master (#8)
by Alessandro
02:58
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 4
    public function __construct(Manager $manager, $databaseName, array $options = [], DataCollectorLoggerInterface $logger)
30
    {
31 4
        parent::__construct($manager, $databaseName, $options);
32 4
        $this->logger = $logger;
33 4
    }
34
35
    /**
36
     * {@inheritdoc}
37
     */
38 1
    public function selectCollection($collectionName, array $options = [])
39
    {
40 1
        $debug = $this->__debugInfo();
41
        $options += [
42 1
            'readConcern' => $debug['readConcern'],
43 1
            'readPreference' => $debug['readPreference'],
44 1
            'typeMap' => $debug['typeMap'],
45 1
            'writeConcern' => $debug['writeConcern'],
46
        ];
47
48 1
        return new Collection($debug['manager'], $debug['databaseName'], $collectionName, $options, $this->logger);
49
    }
50
}
51