Connection::reset()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

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