4
4
5
5
use Crhayes \Validation \Exceptions \ReplacementBindingException ;
6
6
use Crhayes \Validation \Exceptions \ValidatorContextException ;
7
- use Illuminate \Support \ Contracts \MessageProviderInterface ;
7
+ use Illuminate \Contracts \Support \ MessageProvider ;
8
8
use Input ;
9
9
use Validator ;
10
10
11
- abstract class ContextualValidator implements MessageProviderInterface
11
+ abstract class ContextualValidator implements MessageProvider
12
12
{
13
13
const DEFAULT_KEY = 'default ' ;
14
14
15
15
/**
16
16
* Store the attributes we are validating.
17
- *
17
+ *
18
18
* @var array
19
19
*/
20
20
protected $ attributes = array ();
21
21
22
22
/**
23
23
* Store the validation rules.
24
- *
24
+ *
25
25
* @var array
26
26
*/
27
27
protected $ rules = array ();
28
28
29
29
/**
30
30
* Store any custom messages for validation rules.
31
- *
31
+ *
32
32
* @var array
33
33
*/
34
34
protected $ messages = array ();
35
35
36
36
/**
37
37
* Store any contexts we are validating within.
38
- *
38
+ *
39
39
* @var array
40
40
*/
41
41
protected $ contexts = array ();
42
42
43
43
/**
44
44
* Store replacement values for any bindings in our rules.
45
- *
45
+ *
46
46
* @var array
47
47
*/
48
48
protected $ replacements = array ();
49
49
50
50
/**
51
51
* Store any validation messages generated.
52
- *
52
+ *
53
53
* @var array
54
54
*/
55
55
protected $ errors = array ();
56
56
57
57
/**
58
58
* Our constructor will store the attributes we are validating, and
59
- * may also take as a second parameter the contexts within which
59
+ * may also take as a second parameter the contexts within which
60
60
* we are validating.
61
- *
61
+ *
62
62
* @param array $attributes
63
63
* @param mixed $context
64
64
*/
@@ -71,7 +71,7 @@ public function __construct($attributes = null, $context = null)
71
71
72
72
/**
73
73
* Static shorthand for creating a new validator.
74
- *
74
+ *
75
75
* @param mixed $validator
76
76
* @return Crhayes\Validation\GroupedValidator
77
77
*/
@@ -83,7 +83,7 @@ public static function make($attributes = null, $context = null)
83
83
/**
84
84
* Stub method that can be extended by child classes.
85
85
* Passes a validator object and allows for adding complex conditional validations.
86
- *
86
+ *
87
87
* @param \Illuminate\Validation\Validator $validator
88
88
*/
89
89
protected function addConditionalRules ($ validator ) {}
@@ -113,13 +113,13 @@ public function getAttributes()
113
113
114
114
/**
115
115
* Add a validation context.
116
- *
116
+ *
117
117
* @param array $context
118
118
*/
119
119
public function addContext ($ context )
120
120
{
121
121
$ context = is_array ($ context ) ? $ context : array ($ context );
122
-
122
+
123
123
$ this ->contexts = array_merge ($ this ->contexts , $ context );
124
124
125
125
return $ this ;
@@ -140,7 +140,7 @@ public function setContext($context)
140
140
141
141
/**
142
142
* Retrieve the valiation context.
143
- *
143
+ *
144
144
* @return array
145
145
*/
146
146
public function getContexts ()
@@ -150,7 +150,7 @@ public function getContexts()
150
150
151
151
/**
152
152
* Bind a replacement value to a placeholder in a rule.
153
- *
153
+ *
154
154
* @param string $field
155
155
* @param array $replacement
156
156
* @return Crhayes\Validation\ContextualValidator
@@ -164,7 +164,7 @@ public function bindReplacement($field, array $replacement)
164
164
165
165
/**
166
166
* Get a bound replacement by key.
167
- *
167
+ *
168
168
* @param string $key
169
169
* @return array
170
170
*/
@@ -175,7 +175,7 @@ public function getReplacement($key)
175
175
176
176
/**
177
177
* Perform a validation check against our attributes.
178
- *
178
+ *
179
179
* @return boolean
180
180
*/
181
181
public function passes ()
@@ -215,7 +215,7 @@ public function getMessageBag()
215
215
216
216
/**
217
217
* Return any errors.
218
- *
218
+ *
219
219
* @return Illuminate\Support\MessageBag
220
220
*/
221
221
public function errors ()
@@ -227,7 +227,7 @@ public function errors()
227
227
228
228
/**
229
229
* Get the validaton rules within the context of the current validation.
230
- *
230
+ *
231
231
* @return array
232
232
*/
233
233
protected function getRulesInContext ()
@@ -242,8 +242,8 @@ protected function getRulesInContext()
242
242
{
243
243
throw new ValidatorContextException (
244
244
sprintf (
245
- "'%s' does not contain the validation context '%s' " ,
246
- get_called_class (),
245
+ "'%s' does not contain the validation context '%s' " ,
246
+ get_called_class (),
247
247
$ context
248
248
)
249
249
);
@@ -258,7 +258,7 @@ protected function getRulesInContext()
258
258
/**
259
259
* Spin through our contextual rules array and bind any replacement
260
260
* values to placeholders within the rules.
261
- *
261
+ *
262
262
* @param array $rules
263
263
* @return array
264
264
*/
@@ -296,7 +296,7 @@ protected function bindReplacements($rules)
296
296
297
297
/**
298
298
* Check if the current validation has a context.
299
- *
299
+ *
300
300
* @return boolean
301
301
*/
302
302
protected function hasContext ()
0 commit comments