Connection   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 9
c 0
b 0
f 0
dl 0
loc 21
ccs 7
cts 7
cp 1
rs 10
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A reset() 0 3 1
A get() 0 9 3
1
<?php
2
/**
3
 * This file is part of the eav package.
4
 * @author    Alex Kuperwood <[email protected]>
5
 * @copyright 2025 Alex Kuperwood
6
 * @license   https://opensource.org/license/mit  The MIT License
7
 */
8
declare(strict_types=1);
9
10
namespace Kuperwood\Eav\Database;
11
12
use Kuperwood\Eav\Exception\ConnectionException;
13
use PDO;
14
15
class Connection
16
{
17
    protected static ?PDO $conn = null;
18
19
    public static function reset() : void
20
    {
21 1
        self::$conn = null;
22
    }
23 1
24
    /**
25
     * @throws ConnectionException
26
     */
27
    public static function get(PDO $pdo = null) : ?PDO
28
    {
29 3
        if ($pdo instanceof PDO) {
30
            self::$conn = $pdo;
31 3
            return self::$conn;
32 1
        } else if (self::$conn instanceof PDO) {
33
            return self::$conn;
34 3
        }
35 2
        ConnectionException::undefined();
36 2
    }
37
38
}