ErrorTrait   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 70
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
c 1
b 0
f 0
dl 0
loc 70
rs 10
wmc 8

7 Methods

Rating   Name   Duplication   Size   Complexity  
A setError() 0 3 1
A errno() 0 3 1
A hasErrno() 0 3 1
A errorMessage() 0 3 2
A error() 0 3 1
A setErrno() 0 3 1
A hasError() 0 3 1
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(int $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