ConnectionFactory::load()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 17
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 3.3332

Importance

Changes 4
Bugs 1 Features 0
Metric Value
cc 3
eloc 9
c 4
b 1
f 0
nc 3
nop 0
dl 0
loc 17
ccs 8
cts 12
cp 0.6667
crap 3.3332
rs 9.4285
1
<?php
2
3
namespace Opeyemiabiodun\PotatoORM\Connections;
4
5
use Dotenv\Dotenv;
6
7
class ConnectionFactory
0 ignored issues
show
Coding Style introduced by
Since you have declared the constructor as private, maybe you should also declare the class as final.
Loading history...
8
{
9
    private static $_sqliteConnection;
10
11
    private function __construct()
12
    {
13
    }
14
15 8
    public static function load()
16
    {
17 8
        $dotenv = new Dotenv(__DIR__.'/../..');
18 8
        $dotenv->load();
19
20 8
        $dotenv->required(['DB_ENGINE'])->allowedValues(['sqlite']);
21
22 8
        switch (getenv('DB_ENGINE')) {
23
24 8
            case 'sqlite':
25 8
                if (self::$_sqliteConnection == null) {
26
                    self::$_sqliteConnection = new SqliteConnection();
27
                }
28
29 8
                return self::$_sqliteConnection;
30
        }
31
    }
32
}
33