Completed
Push — master ( 81e1d8...617a2d )
by Alessandro
63:04 queued 06:11
created

Database::withOptions()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 8

Duplication

Lines 12
Ratio 100 %

Code Coverage

Tests 7
CRAP Score 1

Importance

Changes 0
Metric Value
dl 12
loc 12
ccs 7
cts 7
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 8
nc 1
nop 1
crap 1
1
<?php declare(strict_types = 1);
2
3
namespace Facile\MongoDbBundle\Capsule;
4
5
use MongoDB\Database as MongoDatabase;
6
use MongoDB\Driver\Manager;
7
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
8
9
/**
10
 * Class Database.
11
 * @internal
12
 */
13
final class Database extends MongoDatabase
14
{
15
    /** @var EventDispatcherInterface */
16
    private $eventDispatcher;
17
18
    /**
19
     * Database constructor.
20
     *
21
     * @param Manager                  $manager
22
     * @param string                   $databaseName
23
     * @param array                    $options
24
     * @param EventDispatcherInterface $eventDispatcher
25
     *
26
     * @internal param DataCollectorLoggerInterface $logger
27
     */
28 6
    public function __construct(Manager $manager, $databaseName, array $options = [], EventDispatcherInterface $eventDispatcher)
29
    {
30 6
        parent::__construct($manager, $databaseName, $options);
31 6
        $this->eventDispatcher = $eventDispatcher;
32 6
    }
33
34
    /**
35
     * {@inheritdoc}
36
     */
37 1 View Code Duplication
    public function selectCollection($collectionName, array $options = [])
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
38
    {
39 1
        $debug = $this->__debugInfo();
40
        $options += [
41 1
            'readConcern' => $debug['readConcern'],
42 1
            'readPreference' => $debug['readPreference'],
43 1
            'typeMap' => $debug['typeMap'],
44 1
            'writeConcern' => $debug['writeConcern'],
45
        ];
46
47 1
        return new Collection($debug['manager'], $debug['databaseName'], $collectionName, $options, $this->eventDispatcher);
48
    }
49
50
    /**
51
     * {@inheritdoc}
52
     */
53 1 View Code Duplication
    public function withOptions(array $options = [])
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
54
    {
55 1
        $debug = $this->__debugInfo();
56
        $options += [
57 1
            'readConcern' => $debug['readConcern'],
58 1
            'readPreference' => $debug['readPreference'],
59 1
            'typeMap' => $debug['typeMap'],
60 1
            'writeConcern' => $debug['writeConcern'],
61
        ];
62
63 1
        return new self($debug['manager'], $debug['databaseName'], $options, $this->eventDispatcher);
64
    }
65
}
66