Completed
Push — master ( 18b606...1191a0 )
by yuuki
04:00
created

QueryError::getErrorCode()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
declare(strict_types=1);
3
4
namespace Ytake\PrestoClient;
5
6
/**
7
 * Class QueryError
8
 */
9
final class QueryError
10
{
11
    /** @var string */
12
    private $message = '';
13
14
    /** @var string */
15
    private $sqlState = '';
16
17
    /** @var int */
18
    private $errorCode;
19
20
    /** @var string */
21
    private $errorName;
22
23
    /** @var string */
24
    private $errorType;
25
26
    /** @var \stdClass */
27
    private $failureInfo;
28
29
    /**
30
     * QueryError constructor.
31
     *
32
     * @param \stdClass $jsonContent
33
     */
34
    public function __construct(\stdClass $jsonContent)
35
    {
36
        $this->message = strval($jsonContent->message);
37
        $this->sqlState = $jsonContent->sqlState ?? '';
38
        $this->errorCode = intval($jsonContent->errorCode);
39
        $this->errorName = strval($jsonContent->errorName);
40
        $this->errorType = strval($jsonContent->errorType);
41
        $this->failureInfo = $jsonContent->failureInfo;
42
    }
43
44
    /**
45
     * @return string
46
     */
47
    public function getMessage(): string
48
    {
49
        return $this->message;
50
    }
51
52
    /**
53
     * @return string
54
     */
55
    public function getSqlState(): string
56
    {
57
        return $this->sqlState;
58
    }
59
60
    /**
61
     * @return int
62
     */
63
    public function getErrorCode(): int
64
    {
65
        return $this->errorCode;
66
    }
67
68
    /**
69
     * @return string
70
     */
71
    public function getErrorName(): string
72
    {
73
        return $this->errorName;
74
    }
75
76
    /**
77
     * @return string
78
     */
79
    public function getErrorType(): string
80
    {
81
        return $this->errorType;
82
    }
83
84
    /**
85
     * @return \stdClass
86
     */
87
    public function getFailureInfo(): \stdClass
88
    {
89
        return $this->failureInfo;
90
    }
91
}
92