ValidationExceptionError::getConstraint()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 4
ccs 0
cts 2
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * ValidationExceptionError class file
4
 */
5
6
namespace Graviton\JsonSchemaBundle\Exception;
7
8
/**
9
 * ValidationExceptionError
10
 *
11
 * @author   List of contributors <https://github.com/libgraviton/graviton/graphs/contributors>
12
 * @license  https://opensource.org/licenses/MIT MIT License
13
 * @link     http://swisscom.ch
14
 */
15
class ValidationExceptionError
16
{
17
18
    /**
19
     * @var string
20
     */
21
    private $property;
22
23
    /**
24
     * @var string
25
     */
26
    private $message;
27
28
    /**
29
     * @var string
30
     */
31
    private $constraint;
32
33
    /**
34
     * @param array $error errpr
35
     */
36 1
    public function __construct(array $error)
37
    {
38 1
        if (isset($error['property'])) {
39
            $this->property = $error['property'];
40
        }
41 1
        if (isset($error['message'])) {
42 1
            $this->message = $error['message'];
43
        }
44 1
        if (isset($error['constraint'])) {
45
            $this->constraint = $error['constraint'];
46
        }
47 1
    }
48
49
    /**
50
     * get property path
51
     *
52
     * @return string
53
     */
54
    public function getProperty()
55
    {
56
        return $this->property;
57
    }
58
59
    /**
60
     * get message
61
     *
62
     * @return string
63
     */
64
    public function getMessage()
65
    {
66
        return $this->message;
67
    }
68
69
    /**
70
     * get constraint name
71
     *
72
     * @return string
73
     */
74
    public function getConstraint()
75
    {
76
        return $this->constraint;
77
    }
78
}
79