@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | * @param array $data array of data to be validated. |
17 | 17 | * @return ValidatorInterface current instance of the validator. |
18 | 18 | */ |
19 | - public function with( array $data ); |
|
19 | + public function with(array $data); |
|
20 | 20 | |
21 | 21 | /** |
22 | 22 | * Performs the given validation against the given data passed on "with()". |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | * @return mixed bool TRUE if it passes the validation, FALSE if it fails. For more info, retrieve errors after the fail. |
26 | 26 | * @throws ValidationFunctionDoesNotExist |
27 | 27 | */ |
28 | - public function passes( $setOfRules ); |
|
28 | + public function passes($setOfRules); |
|
29 | 29 | |
30 | 30 | /** |
31 | 31 | * Returns an array of validation errors that may be empty. |
@@ -40,5 +40,5 @@ discard block |
||
40 | 40 | * @param $key string Key to fetch. |
41 | 41 | * @return mixed value for requested key or NULL if key does not exist. |
42 | 42 | */ |
43 | - public function get( $key ); |
|
43 | + public function get($key); |
|
44 | 44 | } |
45 | 45 | \ No newline at end of file |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | /** |
22 | 22 | * @param Factory $validator |
23 | 23 | */ |
24 | - public function __construct( Factory $validator ) |
|
24 | + public function __construct(Factory $validator) |
|
25 | 25 | { |
26 | 26 | $this->validator = $validator; |
27 | 27 | } |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | * @param array $data |
32 | 32 | * @return $this |
33 | 33 | */ |
34 | - public function with( array $data ) |
|
34 | + public function with(array $data) |
|
35 | 35 | { |
36 | 36 | $this->data = $data; |
37 | 37 | return $this; |
@@ -43,21 +43,21 @@ discard block |
||
43 | 43 | * @return bool |
44 | 44 | * @throws ValidationFunctionDoesNotExist |
45 | 45 | */ |
46 | - public function passes( $setOfRules ) |
|
46 | + public function passes($setOfRules) |
|
47 | 47 | { |
48 | - if ( is_string( $setOfRules ) || is_array( $setOfRules ) ) |
|
48 | + if (is_string($setOfRules) || is_array($setOfRules)) |
|
49 | 49 | { |
50 | 50 | $validator = NULL; |
51 | - if ( is_string( $setOfRules ) && method_exists( $this, $setOfRules ) ) $validator = $this->validator->make( $this->data, $this->{$setOfRules}() ); |
|
52 | - else if ( is_array( $setOfRules ) ) $validator = $this->validator->make( $this->data, $setOfRules ); |
|
51 | + if (is_string($setOfRules) && method_exists($this, $setOfRules)) $validator = $this->validator->make($this->data, $this->{$setOfRules}()); |
|
52 | + else if (is_array($setOfRules)) $validator = $this->validator->make($this->data, $setOfRules); |
|
53 | 53 | else |
54 | 54 | { |
55 | 55 | throw new ValidationFunctionDoesNotExist(); |
56 | 56 | } |
57 | 57 | |
58 | - if ( !is_null( $validator ) ) |
|
58 | + if (!is_null($validator)) |
|
59 | 59 | { |
60 | - if( !$validator->fails() ) return TRUE; |
|
60 | + if (!$validator->fails()) return TRUE; |
|
61 | 61 | else $this->errors = $validator->messages()->getMessages(); |
62 | 62 | } |
63 | 63 | } |
@@ -79,9 +79,9 @@ discard block |
||
79 | 79 | * @param $key |
80 | 80 | * @return mixed |
81 | 81 | */ |
82 | - public function get( $key ) |
|
82 | + public function get($key) |
|
83 | 83 | { |
84 | - return @$this->data[ $key ]; |
|
84 | + return @$this->data[$key]; |
|
85 | 85 | } |
86 | 86 | |
87 | 87 |
@@ -48,17 +48,22 @@ |
||
48 | 48 | if ( is_string( $setOfRules ) || is_array( $setOfRules ) ) |
49 | 49 | { |
50 | 50 | $validator = NULL; |
51 | - if ( is_string( $setOfRules ) && method_exists( $this, $setOfRules ) ) $validator = $this->validator->make( $this->data, $this->{$setOfRules}() ); |
|
52 | - else if ( is_array( $setOfRules ) ) $validator = $this->validator->make( $this->data, $setOfRules ); |
|
53 | - else |
|
51 | + if ( is_string( $setOfRules ) && method_exists( $this, $setOfRules ) ) { |
|
52 | + $validator = $this->validator->make( $this->data, $this->{$setOfRules}() ); |
|
53 | + } else if ( is_array( $setOfRules ) ) { |
|
54 | + $validator = $this->validator->make( $this->data, $setOfRules ); |
|
55 | + } else |
|
54 | 56 | { |
55 | 57 | throw new ValidationFunctionDoesNotExist(); |
56 | 58 | } |
57 | 59 | |
58 | 60 | if ( !is_null( $validator ) ) |
59 | 61 | { |
60 | - if( !$validator->fails() ) return TRUE; |
|
61 | - else $this->errors = $validator->messages()->getMessages(); |
|
62 | + if( !$validator->fails() ) { |
|
63 | + return TRUE; |
|
64 | + } else { |
|
65 | + $this->errors = $validator->messages()->getMessages(); |
|
66 | + } |
|
62 | 67 | } |
63 | 68 | } |
64 | 69 |