Completed
Push — master ( 797c9e...b671da )
by Matteo
02:15
created

ManageErrors   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

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

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
trait ManageErrors
6
{
7
    /**
8
     * Return the last error number. A value of 0 means no errors.
9
     *
10
     * @param Connection|null $linkIdentifier
11
     * @return int
12
     */
13
    public function errno(Connection $linkIdentifier = null)
14
    {
15
        $connection = $this->manager->getOpenConnectionOrFail($linkIdentifier);
1 ignored issue
show
Bug introduced by
The property manager does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
16
17
        return (int) $connection->getErrorInfo()[1];
18
    }
19
20
    /**
21
     * Return the last error text.
22
     *
23
     * @param Connection|null $linkIdentifier
24
     * @return string
25
     */
26
    public function error(Connection $linkIdentifier = null)
27
    {
28
        $connection = $this->manager->getOpenConnectionOrFail($linkIdentifier);
29
30
        return $connection->getErrorInfo()[2];
31
    }
32
}
33