ValidatorResult::getLog()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace Volan;
4
5
class ValidatorResult
6
{
7
8
    const ERROR_NODE_HAS_EXCESSIVE_KEYS     = 1;
9
    const ERROR_NODE_HAS_NO_FIELD_TYPE      = 2;
10
    const ERROR_SCHEMA_HAS_NO_ROOT_ELEMENT  = 3;
11
    const ERROR_VALIDATOR_CLASS_NOT_FOUND   = 4;
12
    const ERROR_REQUIRED_FIELD_IS_EMPTY     = 5;
13
    const ERROR_NODE_IS_NOT_VALID           = 6;
14
    const ERROR_NESTED_ELEMENT_NOT_VALID    = 7;
15
16
17
    /**
18
     * @var string
19
     */
20
    protected $log = null;
21
    /**
22
     * Last error.
23
     *
24
     * @var int
25
     */
26
    protected $errorCode = null;
27
28
    /**
29
     * @var string
30
     */
31
    protected $errorMessage = null;
32
33
    /**
34
     * @var string
35
     */
36
    protected $errorNode = null;
37
38
    /**
39
     * Gets error.
40
     *
41
     * @return array
42
     */
43
    public function getErrorInfo()
44
    {
45
        return [
46
            'code'  => $this->getErrorCode(),
47
            'error' => $this->getErrorMessage(),
48
            'node'  => $this->getErrorMessage(),
49
        ];
50
    }
51
52
53
    /**
54
     * Sets error.
55
     *
56
     * @param int    $code
57
     * @param string $message
58
     */
59
    public function setError($code, $node, $message = '')
60
    {
61
        $this->errorCode = $code;
62
        $this->errorNode = $node;
63
        $this->errorMessage = $message;
64
    }
65
66
    /**
67
     * @return string
68
     */
69
    public function getErrorCode()
70
    {
71
        return $this->errorCode;
72
    }
73
74
    /**
75
     * @return string
76
     */
77
    public function getErrorMessage()
78
    {
79
        return $this->errorMessage;
80
    }
81
82
    /**
83
     * @return string
84
     */
85
    public function getErrorNode()
86
    {
87
        return $this->errorNode;
88
    }
89
90
    /**
91
     * @return string
92
     */
93
    public function getLog()
94
    {
95
        return $this->log;
96
    }
97
98
    /**
99
     * @param $log
100
     *
101
     * @return $this
102
     */
103
    public function setLog($log)
104
    {
105
        $this->log = $log;
106
107
        return $this;
108
    }
109
110
111
112
    /**
113
     * @return bool
114
     */
115
    public function isValid()
116
    {
117
        return $this->errorCode === null;
118
    }
119
}
120