ConnectionFactory   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 57.14%

Importance

Changes 4
Bugs 1 Features 0
Metric Value
wmc 4
c 4
b 1
f 0
lcom 1
cbo 3
dl 0
loc 26
ccs 8
cts 14
cp 0.5714
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A load() 0 17 3
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