ValidationFailure   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 74
Duplicated Lines 0 %

Test Coverage

Coverage 89.47%

Importance

Changes 0
Metric Value
eloc 18
dl 0
loc 74
ccs 17
cts 19
cp 0.8947
rs 10
c 0
b 0
f 0
wmc 6

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A getField() 0 3 1
A getMessage() 0 3 1
A getRuleClass() 0 3 1
A jsonSerialize() 0 7 1
A getArgs() 0 3 1
1
<?php
2
3
namespace Mbright\Validation\Failure;
4
5
class ValidationFailure implements \JsonSerializable
6
{
7
    /** @var string */
8
    protected $field;
9
10
    /** @var string */
11
    protected $message;
12
13
    /** @var string */
14
    protected $ruleClass;
15
16
    /** @var array */
17
    protected $args;
18
19
    /**
20
     * ValidationFailure constructor.
21
     *
22
     * @param string $field
23
     * @param string $message
24
     * @param string $ruleClass
25
     * @param array $args
26
     */
27 54
    public function __construct(string $field, string $message, ?string $ruleClass = null, array $args = [])
28
    {
29 54
        $this->field = $field;
30 54
        $this->message = $message;
31 54
        $this->ruleClass = $ruleClass;
32 54
        $this->args = $args;
33 54
    }
34
35
    /**
36
     * @return string
37
     */
38 3
    public function getField(): string
39
    {
40 3
        return $this->field;
41
    }
42
43
    /**
44
     * @return string
45
     */
46 33
    public function getMessage(): string
47
    {
48 33
        return $this->message;
49
    }
50
51
    /**
52
     * @return string
53
     */
54
    public function getRuleClass(): string
55
    {
56
        return $this->ruleClass;
57
    }
58
59
    /**
60
     * @return array
61
     */
62 3
    public function getArgs(): array
63
    {
64 3
        return $this->args;
65
    }
66
67
    /**
68
     * Returns array for json_encode.
69
     *
70
     * @return array
71
     */
72 3
    public function jsonSerialize(): array
73
    {
74
        return [
75 3
            'field' => $this->field,
76 3
            'message' => $this->message,
77 3
            'ruleClass' => $this->ruleClass,
78 3
            'args' => $this->args
79
        ];
80
    }
81
}
82