Completed
Pull Request — master (#268)
by
unknown
03:19
created

Xhgui_Storage_Factory   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 3
dl 0
loc 23
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A factory() 0 14 4
1
<?php
2
3
/**
4
 * Factory for storage classes
5
 */
6
class Xhgui_Storage_Factory
7
{
8
    /**
9
     * @param $config
10
     * @return Xhgui_Storage_File|Xhgui_Storage_Mongo|Xhgui_Storage_PDO
11
     * @throws MongoConnectionException
12
     * @throws MongoException
13
     */
14
    public static function factory($config)
15
    {
16
        switch ($config['save.handler']) {
17
            case 'pdo':
18
                return new \Xhgui_Storage_PDO($config);
19
20
            case 'mongodb':
21
                return new \Xhgui_Storage_Mongo($config);
22
23
            default:
24
            case 'file':
0 ignored issues
show
Unused Code introduced by
case 'file': return ..._Storage_File($config); does not seem to be reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
25
                return new \Xhgui_Storage_File($config);
26
        }
27
    }
28
}
29