ManageErrors   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 30
rs 10
c 0
b 0
f 0
wmc 2
lcom 1
cbo 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A errno() 0 6 1
A error() 0 6 1
1
<?php
2
3
namespace Mattbit\MysqlCompat\BridgeComponents;
4
5
use Mattbit\MysqlCompat\Connection;
6
7
trait ManageErrors
8
{
9
    /**
10
     * Return the last error number. A value of 0 means no errors.
11
     *
12
     * @param Connection|null $linkIdentifier
13
     *
14
     * @return int
15
     */
16
    public function errno(Connection $linkIdentifier = null)
17
    {
18
        $connection = $this->manager->getOpenConnectionOrFail($linkIdentifier);
19
20
        return (int) $connection->getErrorInfo()[1];
21
    }
22
23
    /**
24
     * Return the last error text.
25
     *
26
     * @param Connection|null $linkIdentifier
27
     *
28
     * @return string
29
     */
30
    public function error(Connection $linkIdentifier = null)
31
    {
32
        $connection = $this->manager->getOpenConnectionOrFail($linkIdentifier);
33
34
        return $connection->getErrorInfo()[2];
35
    }
36
}
37