Completed
Push — master ( 8e5e55...6fad72 )
by Iqbal
10:57
created

SnapshotManager   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 3
c 1
b 0
f 1
lcom 0
cbo 3
dl 27
loc 27
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A supportEngines() 4 4 1
A buildEngine() 8 8 2

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
2
/**
3
 * This file is part of the Borobudur-Event-Sourcing package.
4
 *
5
 * (c) Hexacodelabs <http://hexacodelabs.com>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace Borobudur\EventSourcing\Snapshot;
12
13
use Borobudur\EventSourcing\Storage\AbstractStorageManager;
14
use Borobudur\EventSourcing\Storage\Mongo\MongoConfig;
15
16
/**
17
 * @author      Iqbal Maulana <[email protected]>
18
 * @created     8/23/16
19
 */
20 View Code Duplication
class SnapshotManager extends AbstractStorageManager
0 ignored issues
show
Duplication introduced by
This class 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...
21
{
22
    /**
23
     * @var SnapshotInterface[]
24
     */
25
    protected static $instances = array();
26
27
    /**
28
     * {@inheritdoc}
29
     */
30
    protected static function supportEngines()
31
    {
32
        return array('mongodb', 'mongo');
33
    }
34
    
35
    /**
36
     * {@inheritdoc}
37
     */
38
    protected static function buildEngine($engine, $host, $port, $database, $user, $pass)
39
    {
40
        if (in_array($engine, array('mongodb', 'mongo'))) {
41
            return new MongoSnapshot(new MongoConfig($database, $host, $user, $pass, $port));
42
        }
43
        
44
        return null;
45
    }
46
}
47