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

ManageErrors::errno()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 6
rs 9.4285
cc 1
eloc 3
nc 1
nop 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