Passed
Push — main ( 3626c9...5c7dd3 )
by Thierry
01:38
created

ErrorTrait::hasError()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
namespace Lagdo\DbAdmin\Driver;
4
5
trait ErrorTrait
6
{
7
    /**
8
     * The last error code
9
     *
10
     * @var int
11
     */
12
    protected $errno = 0;
13
14
    /**
15
     * The last error message
16
     *
17
     * @var string
18
     */
19
    protected $error = '';
20
21
    /**
22
     * @inheritDoc
23
     */
24
    public function setError(string $error = '')
25
    {
26
        $this->error = $error;
27
    }
28
29
    /**
30
     * @inheritDoc
31
     */
32
    public function error()
33
    {
34
        return $this->error;
35
    }
36
37
    /**
38
     * @inheritDoc
39
     */
40
    public function hasError()
41
    {
42
        return $this->error !== '';
43
    }
44
45
    /**
46
     * @inheritDoc
47
     */
48
    public function setErrno($errno)
49
    {
50
        $this->errno = $errno;
51
    }
52
53
    /**
54
     * @inheritDoc
55
     */
56
    public function errno()
57
    {
58
        return $this->errno;
59
    }
60
61
    /**
62
     * @inheritDoc
63
     */
64
    public function hasErrno()
65
    {
66
        return $this->errno !== 0;
67
    }
68
69
    /**
70
     * @inheritDoc
71
     */
72
    public function errorMessage()
73
    {
74
        return $this->hasErrno() ? '(' . $this->errno() . '): ' . $this->error() : $this->error();
75
    }
76
}
77