QueryBase   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A hasError() 0 3 1
A errorCode() 0 3 2
A errorMessage() 0 3 2
1
<?php declare(strict_types=1);
2
3
/** 
4
 *  ___      _        _
5
 * | _ \__ _| |_ __ _| |__  __ _ ___ ___
6
 * |  _/ _` |  _/ _` | '_ \/ _` (_-</ -_)
7
 * |_| \__,_|\__\__,_|_.__/\__,_/__/\___|
8
 * 
9
 * This file is part of Kristuff\Patabase.
10
 * (c) Kristuff <[email protected]>
11
 *
12
 * For the full copyright and license information, please view the LICENSE
13
 * file that was distributed with this source code.
14
 *
15
 * @version    1.0.1
16
 * @copyright  2017-2022 Christophe Buliard
17
 */
18
19
namespace Kristuff\Patabase\Query;
20
21
/**
22
 * Class QueryBuilder
23
 *
24
 * Abstract base class for queries
25
 */
26
abstract class QueryBase
27
{
28
    /**
29
     * Error
30
     *
31
     * @access protected
32
     * @var    array                $error
33
     */
34
    protected $error = array();
35
36
    /**
37
     * Has error
38
     *
39
     * @access public
40
     * @return bool             True if the last query execution has genaretd an error
41
     */
42
    public function hasError(): bool
43
    {
44
        return !empty($this->error);
45
    }
46
47
    /**
48
     * Error code
49
     *
50
     * @access public
51
     * @return mixed|null      The last error code reported if any, otherwise null. 
52
     */
53
    public function errorCode()
54
    {
55
        return !empty($this->error) ? $this->error['code']: null;
56
    }
57
58
    /**
59
     * Error message
60
     *
61
     * @access public
62
     * @return string|null     The last error message reported if any, otherwise null. 
63
     */
64
    public function errorMessage()
65
    {
66
        return isset($this->error['message']) ? $this->error['message'] : null;
67
    }
68
 
69
}