Completed
Pull Request — 2.x (#121)
by
unknown
02:22
created

Failure   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 86
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 3
Bugs 0 Features 1
Metric Value
wmc 5
c 3
b 0
f 1
lcom 1
cbo 0
dl 0
loc 86
ccs 16
cts 16
cp 1
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 1
A getField() 0 4 1
A getMessage() 0 4 1
A getArgs() 0 4 1
A jsonSerialize() 0 8 1
1
<?php
2
/**
3
 * This file is part of Aura for PHP.
4
 *
5
 * @license http://opensource.org/licenses/bsd-license.php BSD
6
 */
7
namespace Aura\Filter\Failure;
8
9
use JsonSerializable;
10
11
/**
12
 * Represents the failure of a rule specification.
13
 */
14
class Failure implements JsonSerializable
15
{
16
    /**
17
     * The field that failed.
18
     *
19
     * @var string
20
     */
21
    protected $field;
22
23
    /**
24
     * The failure message.
25
     *
26
     * @var string
27
     */
28
    protected $message;
29
30
    /**
31
     * The arguments passed to the rule specification.
32
     *
33
     * @var array
34
     */
35
    protected $args = array();
36
37
    /**
38
     * Constructor.
39
     *
40
     * @param string $field   The field that failed.
41
     * @param string $message The failure message.
42
     * @param array  $args    The arguments passed to the rule specification.
43
     *
44
     * @return self
0 ignored issues
show
Comprehensibility Best Practice introduced by
Adding a @return annotation to constructors is generally not recommended as a constructor does not have a meaningful return value.

Adding a @return annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.

Please refer to the PHP core documentation on constructors.

Loading history...
45
     */
46 9
    public function __construct(
47
        $field,
48
        $message,
49
        array $args = array()
50
    ) {
51 9
        $this->field = $field;
52 9
        $this->message = $message;
53 9
        $this->args = $args;
54 9
    }
55
56
    /**
57
     * Returns the field that failed.
58
     *
59
     * @return string
60
     */
61 1
    public function getField()
62
    {
63 1
        return $this->field;
64
    }
65
66
    /**
67
     * Returns the failure message.
68
     *
69
     * @return string
70
     */
71 8
    public function getMessage()
72
    {
73 8
        return $this->message;
74
    }
75
76
    /**
77
     * Returns the arguments passed to the rule specification.
78
     *
79
     * @return array
80
     */
81 1
    public function getArgs()
82
    {
83 1
        return $this->args;
84
    }
85
86
    /**
87
     * Returns an array for json_encode.
88
     *
89
     * @return array
90
     */
91 1
    public function jsonSerialize()
92
    {
93
        return array(
94 1
            'field' => $this->field,
95 1
            'message' => $this->message,
96 1
            'args' => $this->args,
97 1
        );
98
    }
99
}
100