Completed
Push — master ( afa8c3...2c7ee4 )
by Maciej
14s
created
src/Collection/ErrorCollection.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 namespace WFV\Collection;
3
-defined( 'ABSPATH' ) || die();
3
+defined('ABSPATH') || die();
4 4
 
5 5
 use WFV\Abstraction\Collectable;
6 6
 
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 	 *
27 27
 	 * @param array $labels Human friendly labels for the fields
28 28
 	 */
29
-	function __construct( array $labels = [] ) {
29
+	function __construct(array $labels = []) {
30 30
 		$this->labels = $labels;
31 31
 	}
32 32
 
@@ -38,9 +38,9 @@  discard block
 block discarded – undo
38 38
 	 * @param string $field
39 39
 	 * @return string|null
40 40
 	 */
41
-	public function first( $field ) {
42
-		return ( isset( $this->data[ $field ] ) )
43
-			? array_values( $this->data[ $field ] )[0]
41
+	public function first($field) {
42
+		return (isset($this->data[$field]))
43
+			? array_values($this->data[$field])[0]
44 44
 			: null;
45 45
 	}
46 46
 
@@ -52,9 +52,9 @@  discard block
 block discarded – undo
52 52
 	 * @param string $field
53 53
 	 * @return array|null
54 54
 	 */
55
-	public function get( $field ) {
56
-		return ( isset( $this->data[ $field ] ) )
57
-			? $this->data[ $field ]
55
+	public function get($field) {
56
+		return (isset($this->data[$field]))
57
+			? $this->data[$field]
58 58
 			: null;
59 59
 	}
60 60
 
@@ -66,10 +66,10 @@  discard block
 block discarded – undo
66 66
 	 *
67 67
 	 * @param array $errors
68 68
 	 */
69
-	public function set_errors( array $errors = [] ) {
70
-		$this->data = ( $this->is_populated() )
69
+	public function set_errors(array $errors = []) {
70
+		$this->data = ($this->is_populated())
71 71
 			? $this->data
72
-			: $this->with_labels( $errors );
72
+			: $this->with_labels($errors);
73 73
 	}
74 74
 
75 75
 	/**
@@ -82,9 +82,9 @@  discard block
 block discarded – undo
82 82
 	 * @param string $field
83 83
 	 * @return string
84 84
 	 */
85
-	protected function label( $field ) {
86
-		return ( isset( $this->labels[ $field ] ) )
87
-			? $this->labels[ $field ]
85
+	protected function label($field) {
86
+		return (isset($this->labels[$field]))
87
+			? $this->labels[$field]
88 88
 			: $field;
89 89
 	}
90 90
 
@@ -97,11 +97,11 @@  discard block
 block discarded – undo
97 97
 	 * @param array $errors
98 98
 	 * @return array
99 99
 	 */
100
-	protected function with_labels( $errors ) {
100
+	protected function with_labels($errors) {
101 101
 		$labeled = array();
102
-		foreach( $errors as $field => $messages ) {
103
-			$label = $this->label( $field );
104
-			$labeled[ $field ] = str_replace( '{label}', $label, $errors[ $field ] );
102
+		foreach ($errors as $field => $messages) {
103
+			$label = $this->label($field);
104
+			$labeled[$field] = str_replace('{label}', $label, $errors[$field]);
105 105
 		}
106 106
 		return $labeled;
107 107
 	}
Please login to merge, or discard this patch.
src/Validators/LengthMax.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 namespace WFV\Validators;
3
-defined( 'ABSPATH' ) || die();
3
+defined('ABSPATH') || die();
4 4
 
5 5
 use WFV\Validators\AbstractValidator;
6 6
 
@@ -32,14 +32,14 @@  discard block
 block discarded – undo
32 32
 	 * @param bool (optional) $optional
33 33
 	 * @return bool
34 34
 	 */
35
-	public function validate( $input = null, $optional = false ) {
35
+	public function validate($input = null, $optional = false) {
36 36
 		$args = func_get_args();
37 37
 		$params = $args[2];
38 38
 		$max_value = $params[0];
39 39
 
40 40
 		$v = $this->validator->create();
41
-		return ( $optional )
42
-			? $v->optional( $v->create()->length( null, $max_value ) )->validate( $input )
43
-			: $v->length( null, $max_value )->validate( $input );
41
+		return ($optional)
42
+			? $v->optional($v->create()->length(null, $max_value))->validate($input)
43
+			: $v->length(null, $max_value)->validate($input);
44 44
 	}
45 45
 }
Please login to merge, or discard this patch.
src/Validators/Different.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 namespace WFV\Validators;
3
-defined( 'ABSPATH' ) or die();
3
+defined('ABSPATH') or die();
4 4
 
5 5
 use WFV\Validators\AbstractValidator;
6 6
 
@@ -32,18 +32,18 @@  discard block
 block discarded – undo
32 32
 	 * @param bool (optional) $optional
33 33
 	 * @return bool
34 34
 	 */
35
-	public function validate( $input = null, $optional = false ){
35
+	public function validate($input = null, $optional = false) {
36 36
 		$args = func_get_args();
37 37
 		$params = $args[2];
38 38
 		$other_field = $params[0];
39 39
 
40 40
 		$v = $this->validator->create();
41 41
 
42
-		if( $optional ) {
42
+		if ($optional) {
43 43
 			return $v->optional(
44
-				$v->create()->not( $v->create()->equals( $_POST[ $other_field ] )) )
45
-					->validate( $input );
44
+				$v->create()->not($v->create()->equals($_POST[$other_field])) )
45
+					->validate($input);
46 46
 		}
47
-		return $v->not( $v->create()->equals( $_POST[ $other_field ] ))->validate( $input );
47
+		return $v->not($v->create()->equals($_POST[$other_field]))->validate($input);
48 48
 	}
49 49
 }
Please login to merge, or discard this patch.
src/Validators/LengthMin.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 namespace WFV\Validators;
3
-defined( 'ABSPATH' ) || die();
3
+defined('ABSPATH') || die();
4 4
 
5 5
 use WFV\Validators\AbstractValidator;
6 6
 
@@ -32,14 +32,14 @@  discard block
 block discarded – undo
32 32
 	 * @param bool (optional) $optional
33 33
 	 * @return bool
34 34
 	 */
35
-	public function validate( $input = null, $optional = false ) {
35
+	public function validate($input = null, $optional = false) {
36 36
 		$args = func_get_args();
37 37
 		$params = $args[2];
38 38
 		$min_value = $params[0];
39 39
 
40 40
 		$v = $this->validator->create();
41
-		return ( $optional )
42
-			? $v->optional( $v->create()->length( $min_value, null ) )->validate( $input )
43
-			: $v->length( $min_value, null )->validate( $input );
41
+		return ($optional)
42
+			? $v->optional($v->create()->length($min_value, null))->validate($input)
43
+			: $v->length($min_value, null)->validate($input);
44 44
 	}
45 45
 }
Please login to merge, or discard this patch.
src/Validators/Url.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 namespace WFV\Validators;
3
-defined( 'ABSPATH' ) || die();
3
+defined('ABSPATH') || die();
4 4
 
5 5
 use WFV\Validators\AbstractValidator;
6 6
 
@@ -32,10 +32,10 @@  discard block
 block discarded – undo
32 32
 	 * @param bool (optional) $optional
33 33
 	 * @return bool
34 34
 	 */
35
-	public function validate( $input = null, $optional = false ) {
35
+	public function validate($input = null, $optional = false) {
36 36
 		$v = $this->validator->create();
37
-		return ( $optional )
38
-			? $v->optional( $v->create()->url() )->validate( $input )
39
-			: $v->url()->validate( $input );
37
+		return ($optional)
38
+			? $v->optional($v->create()->url())->validate($input)
39
+			: $v->url()->validate($input);
40 40
 	}
41 41
 }
Please login to merge, or discard this patch.
src/Validators/Phone.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 namespace WFV\Validators;
3
-defined( 'ABSPATH' ) || die();
3
+defined('ABSPATH') || die();
4 4
 
5 5
 use WFV\Validators\AbstractValidator;
6 6
 
@@ -32,10 +32,10 @@  discard block
 block discarded – undo
32 32
 	 * @param bool (optional) $optional
33 33
 	 * @return bool
34 34
 	 */
35
-	public function validate( $input = null, $optional = false ) {
35
+	public function validate($input = null, $optional = false) {
36 36
 		$v = $this->validator->create();
37
-		return ( $optional )
38
-			? $v->optional( $v->create()->phone() )->validate( $input )
39
-			: $v->phone()->validate( $input );
37
+		return ($optional)
38
+			? $v->optional($v->create()->phone())->validate($input)
39
+			: $v->phone()->validate($input);
40 40
 	}
41 41
 }
Please login to merge, or discard this patch.