1 | <?php |
||
20 | class FailureCollection extends ArrayObject |
||
21 | { |
||
22 | /** |
||
23 | * |
||
24 | * Constructor. |
||
25 | * |
||
26 | * @return self |
||
|
|||
27 | * |
||
28 | */ |
||
29 | 13 | public function __construct() |
|
33 | |||
34 | /** |
||
35 | * |
||
36 | * Is the failure collection empty? |
||
37 | * |
||
38 | * @return bool |
||
39 | * |
||
40 | */ |
||
41 | 9 | public function isEmpty() |
|
45 | |||
46 | /** |
||
47 | * |
||
48 | * Set a failure on a field, removing all previous failures. |
||
49 | * |
||
50 | * @param string $field The field that failed. |
||
51 | * |
||
52 | * @param string $message The failure message. |
||
53 | * |
||
54 | * @param array $args The arguments passed to the rule specification. |
||
55 | * |
||
56 | * @return Failure |
||
57 | * |
||
58 | */ |
||
59 | 1 | public function set($field, $message, array $args = array()) |
|
65 | |||
66 | /** |
||
67 | * |
||
68 | * Adds an additional failure on a field. |
||
69 | * |
||
70 | * @param string $field The field that failed. |
||
71 | * |
||
72 | * @param string $message The failure message. |
||
73 | * |
||
74 | * @param array $args The arguments passed to the rule specification. |
||
75 | * |
||
76 | * @return Failure |
||
77 | * |
||
78 | */ |
||
79 | 9 | public function add($field, $message, array $args = array()) |
|
85 | |||
86 | /** |
||
87 | * |
||
88 | * Factory method to return a new Failure object. |
||
89 | * |
||
90 | * @param string $field The field that failed. |
||
91 | * |
||
92 | * @param string $message The failure message. |
||
93 | * |
||
94 | * @param array $args The arguments passed to the rule specification. |
||
95 | * |
||
96 | * @return Failure |
||
97 | * |
||
98 | */ |
||
99 | 9 | protected function newFailure($field, $message, array $args = array()) |
|
103 | |||
104 | /** |
||
105 | * |
||
106 | * Returns all failures for a field. |
||
107 | * |
||
108 | * @param string $field The field name. |
||
109 | * |
||
110 | * @return array |
||
111 | * |
||
112 | */ |
||
113 | 1 | public function forField($field) |
|
121 | |||
122 | /** |
||
123 | * |
||
124 | * Returns all failure messages for all fields. |
||
125 | * |
||
126 | * @return array |
||
127 | * |
||
128 | */ |
||
129 | 7 | public function getMessages() |
|
137 | |||
138 | /** |
||
139 | * |
||
140 | * Returns all failure messages for one field. |
||
141 | * |
||
142 | * @param string $field The field name. |
||
143 | * |
||
144 | * @return array |
||
145 | * |
||
146 | */ |
||
147 | 7 | public function getMessagesForField($field) |
|
159 | |||
160 | /** |
||
161 | * |
||
162 | * Returns a single string of all failure messages for all fields. |
||
163 | * |
||
164 | * @param string $prefix Prefix each line with this string. |
||
165 | * |
||
166 | * @return string |
||
167 | * |
||
168 | */ |
||
169 | 1 | public function getMessagesAsString($prefix = '') |
|
180 | |||
181 | /** |
||
182 | * |
||
183 | * Returns a single string of all failure messages for one field. |
||
184 | * |
||
185 | * @param string $field The field name. |
||
186 | * |
||
187 | * @param string $prefix Prefix each line with this string. |
||
188 | * |
||
189 | * @return string |
||
190 | * |
||
191 | */ |
||
192 | 1 | public function getMessagesForFieldAsString($field, $prefix = '') |
|
201 | } |
||
202 |
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.