Test Failed
Branch main (8f4107)
by Bingo
08:27 queued 02:15
created

DeadlockCodes   A

Complexity

Total Complexity 13

Size/Duplication

Total Lines 60
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 13
eloc 26
c 1
b 0
f 0
dl 0
loc 60
rs 10

7 Methods

Rating   Name   Duplication   Size   Complexity  
A db2() 0 6 2
A equals() 0 3 2
A mssql() 0 6 2
A postgres() 0 6 2
A oracle() 0 6 2
A mariadbMysql() 0 6 2
A __construct() 0 4 1
1
<?php
2
3
namespace Jabe\Engine\Impl\Util;
4
5
class DeadlockCodes
6
{
7
    private static $POSTGRES;
8
    private static $MARIADB_MYSQL;
9
    private static $MSSQL;
10
    private static $DB2;
11
    private static $ORACLE;
12
13
    private $errorCode;
14
    private $sqlState;
15
16
    public static function postgres(): DeadlockCodes
17
    {
18
        if (self::$POSTGRES === null) {
19
            self::$POSTGRES = new DeadlockCodes(0, "40P01");
20
        }
21
        return self::$POSTGRES;
22
    }
23
24
    public static function mariadbMysql(): DeadlockCodes
25
    {
26
        if (self::$MARIADB_MYSQL === null) {
27
            self::$MARIADB_MYSQL = new DeadlockCodes(1213, "40001");
28
        }
29
        return self::$MARIADB_MYSQL;
30
    }
31
32
    public static function mssql(): DeadlockCodes
33
    {
34
        if (self::$MSSQL === null) {
35
            self::$MSSQL = new DeadlockCodes(1205, "40001");
36
        }
37
        return self::$MSSQL;
38
    }
39
40
    public static function db2(): DeadlockCodes
41
    {
42
        if (self::$DB2 === null) {
43
            self::$DB2 = new DeadlockCodes(-911, "40001");
44
        }
45
        return self::$DB2;
46
    }
47
48
    public static function oracle(): DeadlockCodes
49
    {
50
        if (self::$ORACLE === null) {
51
            self::$ORACLE = new DeadlockCodes(60, "61000");
52
        }
53
        return self::$ORACLE;
54
    }
55
56
    private function __construct(int $errorCode, ?string $sqlState)
57
    {
58
        $this->errorCode = $errorCode;
59
        $this->sqlState = $sqlState;
60
    }
61
62
    public function equals(int $errorCode, ?string $sqlState): bool
63
    {
64
        return $this->errorCode == $errorCode && $this->sqlState == $sqlState;
65
    }
66
}
67