88 * Class AbstractValidator
99 * @package Prettus\Validator
1010 */
11- abstract class AbstractValidator implements ValidatorInterface {
12-
11+ abstract class AbstractValidator implements ValidatorInterface
12+ {
1313 /**
1414 * @var int
1515 */
@@ -64,7 +64,8 @@ abstract class AbstractValidator implements ValidatorInterface {
6464 * @param $id
6565 * @return $this
6666 */
67- public function setId ($ id ){
67+ public function setId ($ id )
68+ {
6869 $ this ->id = $ id ;
6970 return $ this ;
7071 }
@@ -108,7 +109,7 @@ public function errorsBag()
108109 * @param string $action
109110 * @return boolean
110111 */
111- abstract public function passes ( $ action = null );
112+ abstract public function passes ($ action = null );
112113
113114 /**
114115 * Pass the data and the rules to the validator or throws ValidatorException
@@ -119,8 +120,8 @@ abstract public function passes( $action = null );
119120 */
120121 public function passesOrFail ($ action = null )
121122 {
122- if ( !$ this ->passes ($ action ) ) {
123- throw new ValidatorException ( $ this ->errorsBag () );
123+ if ( !$ this ->passes ($ action )) {
124+ throw new ValidatorException ($ this ->errorsBag ());
124125 }
125126
126127 return true ;
@@ -134,11 +135,11 @@ public function passesOrFail($action = null)
134135 * @param null $action
135136 * @return array
136137 */
137- public function getRules ($ action = null ){
138-
138+ public function getRules ($ action = null )
139+ {
139140 $ rules = $ this ->rules ;
140141
141- if ( isset ($ this ->rules [$ action ]) ) {
142+ if ( isset ($ this ->rules [$ action ])) {
142143 $ rules = $ this ->rules [$ action ];
143144 }
144145
@@ -162,14 +163,15 @@ public function setRules(array $rules)
162163 *
163164 * @return array
164165 */
165- public function getMessages (){
166-
166+ public function getMessages ()
167+ {
167168 return $ this ->messages ;
168169 }
169170
170171 /**
171172 * Set Custom error messages for Validation
172173 *
174+ * @param array $messages
173175 * @return $this
174176 */
175177 public function setMessages (array $ messages )
@@ -183,14 +185,15 @@ public function setMessages(array $messages)
183185 *
184186 * @return array
185187 */
186- public function getAttributes (){
187-
188+ public function getAttributes ()
189+ {
188190 return $ this ->attributes ;
189191 }
190192
191193 /**
192194 * Set Custom error attributes for Validation
193195 *
196+ * @param array $attributes
194197 * @return $this
195198 */
196199 public function setAttributes (array $ attributes )
@@ -208,33 +211,28 @@ public function setAttributes(array $attributes)
208211 */
209212 protected function parserValidationRules ($ rules , $ id = null )
210213 {
211-
212- if ($ id === null )
213- {
214+ if (null === $ id ) {
214215 return $ rules ;
215216 }
216217
217- array_walk ($ rules , function (&$ rules , $ field ) use ($ id )
218- {
219- if (!is_array ($ rules ))
220- {
218+ array_walk ($ rules , function (&$ rules , $ field ) use ($ id ) {
219+ if (!is_array ($ rules )) {
221220 $ rules = explode ("| " , $ rules );
222221 }
223222
224- foreach ($ rules as $ ruleIdx => $ rule )
225- {
223+ foreach ($ rules as $ ruleIdx => $ rule ) {
226224 // get name and parameters
227225 @list ($ name , $ params ) = array_pad (explode (": " , $ rule ), 2 , null );
228226
229227 // only do someting for the unique rule
230- if (strtolower ($ name ) != "unique " ) {
228+ if (strtolower ($ name ) != "unique " ) {
231229 continue ; // continue in foreach loop, nothing left to do here
232230 }
233231
234232 $ p = array_map ("trim " , explode (", " , $ params ));
235233
236234 // set field name to rules key ($field) (laravel convention)
237- if (!isset ($ p [1 ])) {
235+ if (!isset ($ p [1 ])) {
238236 $ p [1 ] = $ field ;
239237 }
240238
@@ -248,5 +246,4 @@ protected function parserValidationRules($rules, $id = null)
248246
249247 return $ rules ;
250248 }
251-
252- }
249+ }
0 commit comments