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

Database   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 53
Duplicated Lines 45.28 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 2
dl 24
loc 53
ccs 18
cts 18
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A selectCollection() 12 12 1
A withOptions() 12 12 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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