ConnectionFactory::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 4
Bugs 1 Features 0
Metric Value
c 4
b 1
f 0
dl 0
loc 3
ccs 0
cts 2
cp 0
rs 10
cc 1
eloc 1
nc 1
nop 0
crap 2
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