Completed
Push — master ( aad1d1...54b5b7 )
by Maciej
12s
created
src/Contract/CollectionInterface.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 namespace WFV\Contract;
3
-defined( 'ABSPATH' ) || die();
3
+defined('ABSPATH') || die();
4 4
 
5 5
 /**
6 6
  *
@@ -12,12 +12,12 @@  discard block
 block discarded – undo
12 12
 	/**
13 13
 	 * @return bool
14 14
 	 */
15
-	public function contains( $key = null, $value = null );
15
+	public function contains($key = null, $value = null);
16 16
 
17 17
 	/**
18 18
 	 * @return bool
19 19
 	 */
20
-	public function has( $key = null );
20
+	public function has($key = null);
21 21
 
22 22
 	/**
23 23
 	 * @return bool
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 	/**
28 28
 	 * @return string|null
29 29
 	 */
30
-	public function escape( $key, callable $callback = null );
30
+	public function escape($key, callable $callback = null);
31 31
 
32 32
 	/**
33 33
 	 * @return
Please login to merge, or discard this patch.
src/Contract/ArtisanInterface.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 namespace WFV\Contract;
3
-defined( 'ABSPATH' ) || die();
3
+defined('ABSPATH') || die();
4 4
 
5 5
 /**
6 6
  *
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 	/**
14 14
 	 * @return
15 15
 	 */
16
-	public function create( $action );
16
+	public function create($action);
17 17
 
18 18
 	/**
19 19
 	 * @return
Please login to merge, or discard this patch.
src/Abstraction/Collectable.php 2 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
 	 * @access private
109 109
 	 *
110 110
 	 * @param array $array
111
-	 * @param string|array $callback
111
+	 * @param callable $callback
112 112
 	 * @return array
113 113
 	 */
114 114
 	protected function transform_array_leafs( array $array, $callback ) {
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
 	 * @since 0.10.0
125 125
 	 * @access private
126 126
 	 *
127
-	 * @param string|array $callback
127
+	 * @param callable $callback
128 128
 	 * @param string (optional) $input The input string
129 129
 	 * @return
130 130
 	 */
Please login to merge, or discard this patch.
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 namespace WFV\Abstraction;
3
-defined( 'ABSPATH' ) || die();
3
+defined('ABSPATH') || die();
4 4
 
5 5
 use WFV\Contract\CollectionInterface;
6 6
 
@@ -29,11 +29,11 @@  discard block
 block discarded – undo
29 29
 	 * @param string $value
30 30
 	 * @return bool
31 31
 	 */
32
-	public function contains( $key = null, $value = null ) {
33
-		if( $this->has( $key ) ) {
34
-			return ( is_array( $this->data[ $key ] ) )
35
-				? in_array( $value, $this->data[ $key ] )
36
-				: $this->data[ $key ] === $value;
32
+	public function contains($key = null, $value = null) {
33
+		if ($this->has($key)) {
34
+			return (is_array($this->data[$key]))
35
+				? in_array($value, $this->data[$key])
36
+				: $this->data[$key] === $value;
37 37
 		}
38 38
 		return false;
39 39
 	}
@@ -47,10 +47,10 @@  discard block
 block discarded – undo
47 47
 	 * @param string|array (optional) $callback Context appropriate callable.
48 48
 	 * @return string|null
49 49
 	 */
50
-	public function escape( $key, callable $callback = null ) {
51
-		if( is_string( $key ) ) {
52
-			$callback = ( null === $callback ) ? 'esc_html' : $callback;
53
-			return ( true === $this->has( $key ) ) ? $this->call_func( $callback, $this->data[ $key ] ) : null;
50
+	public function escape($key, callable $callback = null) {
51
+		if (is_string($key)) {
52
+			$callback = (null === $callback) ? 'esc_html' : $callback;
53
+			return (true === $this->has($key)) ? $this->call_func($callback, $this->data[$key]) : null;
54 54
 		}
55 55
 		return null;
56 56
 	}
@@ -63,8 +63,8 @@  discard block
 block discarded – undo
63 63
 	 * @param string $key
64 64
 	 * @return bool
65 65
 	 */
66
-	public function has( $key = null ) {
67
-		return array_key_exists( $key, $this->data );
66
+	public function has($key = null) {
67
+		return array_key_exists($key, $this->data);
68 68
 	}
69 69
 
70 70
 	/**
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
 	 * @return bool
76 76
 	 */
77 77
 	public function is_populated() {
78
-		return count( $this->data ) > 0;
78
+		return count($this->data) > 0;
79 79
 	}
80 80
 
81 81
 	/**
@@ -88,11 +88,11 @@  discard block
 block discarded – undo
88 88
 	 * @param callable $callback
89 89
 	 * @return array
90 90
 	 */
91
-	public function transform( $key = null, callable $callback ) {
91
+	public function transform($key = null, callable $callback) {
92 92
 		// WIP
93
-		if( true === $this->has( $key ) ) {
94
-			if( is_array( $this->data[ $key ] ) ) {
95
-				return $this->transform_array_leafs( $this->data[ $key ], $callback );
93
+		if (true === $this->has($key)) {
94
+			if (is_array($this->data[$key])) {
95
+				return $this->transform_array_leafs($this->data[$key], $callback);
96 96
 			}
97 97
 		}
98 98
 	}
@@ -109,9 +109,9 @@  discard block
 block discarded – undo
109 109
 	 * @param string|array $callback
110 110
 	 * @return array
111 111
 	 */
112
-	protected function transform_array_leafs( array $array, $callback ) {
113
-		array_walk_recursive( $array, function( &$item ) use( $callback ) {
114
-			$item = $this->call_func( $callback, $item );
112
+	protected function transform_array_leafs(array $array, $callback) {
113
+		array_walk_recursive($array, function(&$item) use($callback) {
114
+			$item = $this->call_func($callback, $item);
115 115
 		} );
116 116
 		return $array;
117 117
 	}
@@ -126,16 +126,16 @@  discard block
 block discarded – undo
126 126
 	 * @param string (optional) $input The input string
127 127
 	 * @return
128 128
 	 */
129
-	private function call_func( $callback, $input = null ) {
129
+	private function call_func($callback, $input = null) {
130 130
 		// WIP - simplify
131
-		if( is_array( $callback ) ) {
131
+		if (is_array($callback)) {
132 132
 			$method = $callback[0];
133 133
 			$args = $callback[1];
134
-			if ( $input ) {
135
-				array_unshift( $args, $input );
134
+			if ($input) {
135
+				array_unshift($args, $input);
136 136
 			}
137
-			return call_user_func_array( $method, $args );
137
+			return call_user_func_array($method, $args);
138 138
 		}
139
-		return $callback( $input );
139
+		return $callback($input);
140 140
 	}
141 141
 }
Please login to merge, or discard this patch.
src/Collection/InputCollection.php 1 patch
Spacing   +8 added lines, -8 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
 
@@ -20,9 +20,9 @@  discard block
 block discarded – undo
20 20
 	 * @param array $data
21 21
 	 * @param bool $trim
22 22
 	 */
23
-	public function __construct( array $data = array(), $trim ) {
24
-		$data = $this->transform_array_leafs( $data, 'stripslashes' );
25
-		$this->data = ( $trim ) ? $this->transform_array_leafs( $data, 'trim' ) : $data;
23
+	public function __construct(array $data = array(), $trim) {
24
+		$data = $this->transform_array_leafs($data, 'stripslashes');
25
+		$this->data = ($trim) ? $this->transform_array_leafs($data, 'trim') : $data;
26 26
 	}
27 27
 
28 28
 	/**
@@ -33,8 +33,8 @@  discard block
 block discarded – undo
33 33
 	 * @param bool $tokens With or without token and action attributes.
34 34
 	 * @return array
35 35
 	 */
36
-	public function get_array( $tokens = true ) {
37
-		return ( $tokens ) ? $this->data : $this->neat_array();
36
+	public function get_array($tokens = true) {
37
+		return ($tokens) ? $this->data : $this->neat_array();
38 38
 	}
39 39
 
40 40
 	/**
@@ -47,8 +47,8 @@  discard block
 block discarded – undo
47 47
 	 */
48 48
 	protected function neat_array() {
49 49
 		$input = $this->data;
50
-		unset( $input[ $input['action'] .'_token'] );
51
-		unset( $input['action'] );
50
+		unset($input[$input['action'].'_token']);
51
+		unset($input['action']);
52 52
 		return $input;
53 53
 	}
54 54
 }
Please login to merge, or discard this patch.
src/Artisan/Director.php 2 patches
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
    * @param string (optional) $identity
48 48
    */
49 49
   public function __construct( $identity = null ) {
50
-    $this->entity = $identity;
50
+	$this->entity = $identity;
51 51
   }
52 52
 
53 53
   /**
@@ -60,8 +60,8 @@  discard block
 block discarded – undo
60 60
    * @return self
61 61
    */
62 62
   public function describe( $attribute, $characteristic ) {
63
-    $this->scribe[ $attribute ] = $characteristic;
64
-    return $this;
63
+	$this->scribe[ $attribute ] = $characteristic;
64
+	return $this;
65 65
   }
66 66
 
67 67
   /**
@@ -73,10 +73,10 @@  discard block
 block discarded – undo
73 73
    * @return Composite
74 74
    */
75 75
   public function compose( ArtisanInterface $artisan ) {
76
-    $this->orchestrate( $this->aspect, $artisan );
77
-    return $artisan
78
-      ->create( $this->entity )
79
-      ->actualize();
76
+	$this->orchestrate( $this->aspect, $artisan );
77
+	return $artisan
78
+	  ->create( $this->entity )
79
+	  ->actualize();
80 80
   }
81 81
 
82 82
   /**
@@ -89,8 +89,8 @@  discard block
 block discarded – undo
89 89
    * @return self
90 90
    */
91 91
   public function with( $quality, $attributes = null ) {
92
-    $this->aspect[ $quality ] = $attributes;
93
-    return $this;
92
+	$this->aspect[ $quality ] = $attributes;
93
+	return $this;
94 94
   }
95 95
 
96 96
   /**
@@ -103,8 +103,8 @@  discard block
 block discarded – undo
103 103
    * @param ArtisanInterface $artisan
104 104
    */
105 105
   private function orchestrate( array $aspect, ArtisanInterface &$artisan ) {
106
-    foreach( $aspect as $component => $params ) {
107
-      $artisan->$component( $params );
108
-    }
106
+	foreach( $aspect as $component => $params ) {
107
+	  $artisan->$component( $params );
108
+	}
109 109
   }
110 110
 }
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 namespace WFV\Artisan;
3
-defined( 'ABSPATH' ) || die( 'envois' );
3
+defined('ABSPATH') || die('envois');
4 4
 
5 5
 use WFV\Contract\ArtisanInterface;
6 6
 
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
    *
47 47
    * @param string (optional) $identity
48 48
    */
49
-  public function __construct( $identity = null ) {
49
+  public function __construct($identity = null) {
50 50
     $this->entity = $identity;
51 51
   }
52 52
 
@@ -59,8 +59,8 @@  discard block
 block discarded – undo
59 59
    * @param mixed $characteristic
60 60
    * @return self
61 61
    */
62
-  public function describe( $attribute, $characteristic ) {
63
-    $this->scribe[ $attribute ] = $characteristic;
62
+  public function describe($attribute, $characteristic) {
63
+    $this->scribe[$attribute] = $characteristic;
64 64
     return $this;
65 65
   }
66 66
 
@@ -72,10 +72,10 @@  discard block
 block discarded – undo
72 72
    * @param ArtisanInterface $artisan
73 73
    * @return Composite
74 74
    */
75
-  public function compose( ArtisanInterface $artisan ) {
76
-    $this->orchestrate( $this->aspect, $artisan );
75
+  public function compose(ArtisanInterface $artisan) {
76
+    $this->orchestrate($this->aspect, $artisan);
77 77
     return $artisan
78
-      ->create( $this->entity )
78
+      ->create($this->entity)
79 79
       ->actualize();
80 80
   }
81 81
 
@@ -88,8 +88,8 @@  discard block
 block discarded – undo
88 88
    * @param string|array (optional) $attributes
89 89
    * @return self
90 90
    */
91
-  public function with( $quality, $attributes = null ) {
92
-    $this->aspect[ $quality ] = $attributes;
91
+  public function with($quality, $attributes = null) {
92
+    $this->aspect[$quality] = $attributes;
93 93
     return $this;
94 94
   }
95 95
 
@@ -102,9 +102,9 @@  discard block
 block discarded – undo
102 102
    * @param array $aspect
103 103
    * @param ArtisanInterface $artisan
104 104
    */
105
-  private function orchestrate( array $aspect, ArtisanInterface &$artisan ) {
106
-    foreach( $aspect as $component => $params ) {
107
-      $artisan->$component( $params );
105
+  private function orchestrate(array $aspect, ArtisanInterface&$artisan) {
106
+    foreach ($aspect as $component => $params) {
107
+      $artisan->$component($params);
108 108
     }
109 109
   }
110 110
 }
Please login to merge, or discard this patch.
src/Agent/InspectionAgent.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 namespace WFV\Agent;
3
-defined( 'ABSPATH' ) || die();
3
+defined('ABSPATH') || die();
4 4
 
5 5
 
6 6
 /**
@@ -35,9 +35,9 @@  discard block
 block discarded – undo
35 35
 	 *
36 36
 	 * @param string $action
37 37
 	 */
38
-	public function __construct( $action ) {
38
+	public function __construct($action) {
39 39
 		$this->action = $action;
40
-		$this->token = wp_create_nonce( $action );
40
+		$this->token = wp_create_nonce($action);
41 41
 	}
42 42
 
43 43
 	/**
@@ -50,8 +50,8 @@  discard block
 block discarded – undo
50 50
 	 * @return bool
51 51
 	 */
52 52
 	public function safe_submit() {
53
-		if( $this->submit_has_action() ) {
54
-			return ( $_POST['action'] === $this->action ) ? $this->nonce() : false;
53
+		if ($this->submit_has_action()) {
54
+			return ($_POST['action'] === $this->action) ? $this->nonce() : false;
55 55
 		}
56 56
 		return false;
57 57
 	}
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
 	 * @return bool
65 65
 	 */
66 66
 	private function submit_has_action() {
67
-		return isset( $_POST['action'] );
67
+		return isset($_POST['action']);
68 68
 	}
69 69
 
70 70
 	/**
@@ -76,8 +76,8 @@  discard block
 block discarded – undo
76 76
 	 * @return bool
77 77
 	 */
78 78
 	private function nonce() {
79
-		$nonce = $_REQUEST[ $this->action.'_token' ];
80
-		return ( wp_verify_nonce( $nonce, $this->action ) ) ? true : false;
79
+		$nonce = $_REQUEST[$this->action.'_token'];
80
+		return (wp_verify_nonce($nonce, $this->action)) ? true : false;
81 81
 	}
82 82
 
83 83
 }
Please login to merge, or discard this patch.
src/FormComposite.php 3 patches
Doc Comments   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 	 *
28 28
 	 * @since 0.10.0
29 29
 	 *
30
-	 * @param ArtisanInterface $builder
30
+	 * @param FormArtisan $builder
31 31
 	 * @param string $action
32 32
 	 */
33 33
 	public function __construct( FormArtisan $builder, $action ) {
@@ -194,6 +194,8 @@  discard block
 block discarded – undo
194 194
 	 * @param string $response
195 195
 	 * @param string (optional) $field
196 196
 	 * @param string (optional) $value
197
+	 * @param string $field
198
+	 * @param string $value
197 199
 	 * @return string|null
198 200
 	 */
199 201
 	protected function string_or_null( $response, $field = null, $value = null ) {
Please login to merge, or discard this patch.
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -3,7 +3,6 @@
 block discarded – undo
3 3
 defined( 'ABSPATH' ) || die();
4 4
 
5 5
 use WFV\Artisan\FormArtisan;
6
-use WFV\Contract\ValidateInterface;
7 6
 use WFV\Factory\ValidatorFactory;
8 7
 
9 8
 /**
Please login to merge, or discard this patch.
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 namespace WFV;
3
-defined( 'ABSPATH' ) || die();
3
+defined('ABSPATH') || die();
4 4
 
5 5
 use WFV\Artisan\FormArtisan;
6 6
 use WFV\Contract\ValidateInterface;
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 	 * @param ArtisanInterface $builder
49 49
 	 * @param string $action
50 50
 	 */
51
-	public function __construct( FormArtisan $builder, $action ) {
51
+	public function __construct(FormArtisan $builder, $action) {
52 52
 		$this->alias = $action;
53 53
 		$this->collection = $builder->collection;
54 54
 		$this->validator = $builder->validator;
@@ -63,8 +63,8 @@  discard block
 block discarded – undo
63 63
 	 * @param string $value Value to compare against.
64 64
 	 * @return string|null
65 65
 	 */
66
-	public function checked_if( $field = null, $value = null ) {
67
-		return $this->string_or_null( 'checked', $field, $value );
66
+	public function checked_if($field = null, $value = null) {
67
+		return $this->string_or_null('checked', $field, $value);
68 68
 	}
69 69
 
70 70
 	/**
@@ -78,8 +78,8 @@  discard block
 block discarded – undo
78 78
 	 * @param callable (optional) $callback
79 79
 	 * @return string
80 80
 	 */
81
-	public function display( $field = null, callable $callback = null ) {
82
-		echo $input = $this->utilize('input')->escape( $field );
81
+	public function display($field = null, callable $callback = null) {
82
+		echo $input = $this->utilize('input')->escape($field);
83 83
 		return $input;
84 84
 	}
85 85
 
@@ -117,10 +117,10 @@  discard block
 block discarded – undo
117 117
 	 */
118 118
 	public function is_valid() {
119 119
 		$is_valid = $this->validator->is_valid();
120
-		if( false === $is_valid ) {
121
-			$this->utilize('errors')->set_errors( $this->validator->errors() );
120
+		if (false === $is_valid) {
121
+			$this->utilize('errors')->set_errors($this->validator->errors());
122 122
 		}
123
-		$this->trigger_post_validate_action( $is_valid );
123
+		$this->trigger_post_validate_action($is_valid);
124 124
 		return $is_valid;
125 125
 	}
126 126
 
@@ -144,8 +144,8 @@  discard block
 block discarded – undo
144 144
 	 * @param string $value Value to compare against.
145 145
 	 * @return string|null
146 146
 	 */
147
-	public function selected_if( $field = null, $value = null ) {
148
-		return $this->string_or_null( 'selected', $field, $value );
147
+	public function selected_if($field = null, $value = null) {
148
+		return $this->string_or_null('selected', $field, $value);
149 149
 	}
150 150
 
151 151
 	/**
@@ -157,9 +157,9 @@  discard block
 block discarded – undo
157 157
 	 */
158 158
 	public function token_fields() {
159 159
 		// TODO - Move markup into something - perhaps a renderable interface?
160
-		$token_name = $this->alias . '_token';
161
-		echo $nonce_field = wp_nonce_field( $this->alias, $token_name, false, false );
162
-		echo $action_field = '<input type="hidden" name="action" value="'. $this->alias .'">';
160
+		$token_name = $this->alias.'_token';
161
+		echo $nonce_field = wp_nonce_field($this->alias, $token_name, false, false);
162
+		echo $action_field = '<input type="hidden" name="action" value="'.$this->alias.'">';
163 163
 	}
164 164
 
165 165
 	/**
@@ -170,17 +170,17 @@  discard block
 block discarded – undo
170 170
 	 * @param ValidatorFactory $factory
171 171
 	 * @return self
172 172
 	 */
173
-	public function validate( ValidatorFactory $factory ) {
173
+	public function validate(ValidatorFactory $factory) {
174 174
 		$rule_collection = $this->utilize('rules');
175
-		$rules = $rule_collection->get_array( true );
175
+		$rules = $rule_collection->get_array(true);
176 176
 
177
-		foreach( $rules as $field => $ruleset ) {
178
-			$input = $this->field_value( $field );
179
-			$optional = $rule_collection->is_optional( $field );
177
+		foreach ($rules as $field => $ruleset) {
178
+			$input = $this->field_value($field);
179
+			$optional = $rule_collection->is_optional($field);
180 180
 
181
-			foreach( $ruleset as $index => $rule ) {
182
-				$params = $rule_collection->get_params( $field, $index );
183
-				$this->validator->validate( $factory->get( $rule ), $field, $input, $optional, $params );
181
+			foreach ($ruleset as $index => $rule) {
182
+				$params = $rule_collection->get_params($field, $index);
183
+				$this->validator->validate($factory->get($rule), $field, $input, $optional, $params);
184 184
 			}
185 185
 		}
186 186
 		return $this;
@@ -195,11 +195,11 @@  discard block
 block discarded – undo
195 195
 	 *
196 196
 	 * @param string $field
197 197
 	 */
198
-	protected function field_value( $field ) {
198
+	protected function field_value($field) {
199 199
 		$input = $this->utilize('input');
200
-		if( $input->has( $field ) ) {
201
-			$input = $input->get_array( false );
202
-			return $input[ $field ];
200
+		if ($input->has($field)) {
201
+			$input = $input->get_array(false);
202
+			return $input[$field];
203 203
 		}
204 204
 		return null;
205 205
 	}
@@ -215,8 +215,8 @@  discard block
 block discarded – undo
215 215
 	 * @param string (optional) $value
216 216
 	 * @return string|null
217 217
 	 */
218
-	protected function string_or_null( $response, $field = null, $value = null ) {
219
-		return ( $this->input( $field )->contains( $field, $value ) ) ? $response : null;
218
+	protected function string_or_null($response, $field = null, $value = null) {
219
+		return ($this->input($field)->contains($field, $value)) ? $response : null;
220 220
 	}
221 221
 
222 222
 	/**
@@ -227,9 +227,9 @@  discard block
 block discarded – undo
227 227
 	 *
228 228
 	 * @param bool $is_valid
229 229
 	 */
230
-	protected function trigger_post_validate_action( $is_valid = false ) {
231
-		$action = ( true === $is_valid ) ? $this->alias : $this->alias .'_fail';
232
-		do_action( $action, $this );
230
+	protected function trigger_post_validate_action($is_valid = false) {
231
+		$action = (true === $is_valid) ? $this->alias : $this->alias.'_fail';
232
+		do_action($action, $this);
233 233
 	}
234 234
 
235 235
 	/**
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
 	 *
241 241
 	 * @param string $component Key indentifier.
242 242
 	 */
243
-	protected function utilize( $component ) {
244
-		return $this->collection[ $component ];
243
+	protected function utilize($component) {
244
+		return $this->collection[$component];
245 245
 	}
246 246
 }
Please login to merge, or discard this patch.
src/Collection/RuleCollection.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -143,7 +143,7 @@
 block discarded – undo
143 143
 	 * @access protected
144 144
 	 *
145 145
 	 * @param string $rule
146
-	 * @return bool
146
+	 * @return integer
147 147
 	 */
148 148
 	protected function string_has_params( $rule ) {
149 149
 		return strpos( $rule, ':' );
Please login to merge, or discard this patch.
Spacing   +42 added lines, -42 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
 
@@ -18,8 +18,8 @@  discard block
 block discarded – undo
18 18
 	 *
19 19
 	 * @param array $rules
20 20
 	 */
21
-	public function __construct( array $rules ) {
22
-		$this->data = $this->parse_rules( $rules );
21
+	public function __construct(array $rules) {
22
+		$this->data = $this->parse_rules($rules);
23 23
 	}
24 24
 
25 25
 
@@ -32,8 +32,8 @@  discard block
 block discarded – undo
32 32
 	 * @param bool (optional) $flat
33 33
 	 * @return array
34 34
 	 */
35
-	public function get_array( $flat = false ) {
36
-		return ( $flat ) ? $this->remove_params() : $this->data;
35
+	public function get_array($flat = false) {
36
+		return ($flat) ? $this->remove_params() : $this->data;
37 37
 	}
38 38
 
39 39
 	/**
@@ -45,9 +45,9 @@  discard block
 block discarded – undo
45 45
 	 * @param int $index
46 46
 	 * @return array|bool
47 47
 	 */
48
-	public function get_params( $field, $index ) {
49
-		return ( $this-> has_params( $field, $index ) )
50
-			? $this->data[ $field ][ $index ]['params']
48
+	public function get_params($field, $index) {
49
+		return ($this-> has_params($field, $index))
50
+			? $this->data[$field][$index]['params']
51 51
 			: false;
52 52
 	}
53 53
 
@@ -59,9 +59,9 @@  discard block
 block discarded – undo
59 59
 	 * @param string $field
60 60
 	 * @return bool
61 61
 	 */
62
-	public function is_optional( $field ) {
63
-		if( $this->has( $field ) ){
64
-			return in_array('optional', $this->data[ $field ] );
62
+	public function is_optional($field) {
63
+		if ($this->has($field)) {
64
+			return in_array('optional', $this->data[$field]);
65 65
 		}
66 66
 		return false;
67 67
 	}
@@ -74,8 +74,8 @@  discard block
 block discarded – undo
74 74
 	 * @return array
75 75
 	 */
76 76
 	public function unique() {
77
-		$flat = $this->flatten( $this->remove_params() );
78
-		return array_values( array_unique( $flat ) );
77
+		$flat = $this->flatten($this->remove_params());
78
+		return array_values(array_unique($flat));
79 79
 	}
80 80
 
81 81
 	/**
@@ -87,8 +87,8 @@  discard block
 block discarded – undo
87 87
 	 * @param string $rule
88 88
 	 * @return string
89 89
 	 */
90
-	protected function extract_name( $rule ) {
91
-		return strstr( $rule, ':', true );
90
+	protected function extract_name($rule) {
91
+		return strstr($rule, ':', true);
92 92
 	}
93 93
 
94 94
 	/**
@@ -100,8 +100,8 @@  discard block
 block discarded – undo
100 100
 	 * @param string $rule
101 101
 	 * @return string
102 102
 	 */
103
-	protected function extract_params( $rule ) {
104
-		return ltrim( strstr($rule, ':'), ':');
103
+	protected function extract_params($rule) {
104
+		return ltrim(strstr($rule, ':'), ':');
105 105
 	}
106 106
 
107 107
 	/**
@@ -113,11 +113,11 @@  discard block
 block discarded – undo
113 113
 	 * @param array $array
114 114
 	 * @return array
115 115
 	 */
116
-	protected function flatten( array $array ) {
116
+	protected function flatten(array $array) {
117 117
 		$flat = array();
118
-		foreach( $array as $rule ) {
119
-			if( is_array( $rule ) ){
120
-				$flat = array_merge( $flat, $this->flatten( $rule ) );
118
+		foreach ($array as $rule) {
119
+			if (is_array($rule)) {
120
+				$flat = array_merge($flat, $this->flatten($rule));
121 121
 			} else {
122 122
 				$flat[] = $rule;
123 123
 			}
@@ -135,8 +135,8 @@  discard block
 block discarded – undo
135 135
 	 * @param int $index
136 136
 	 * @return bool
137 137
 	 */
138
-	protected function has_params( $field, $index ) {
139
-		return is_array( $this->data[ $field ][ $index ] );
138
+	protected function has_params($field, $index) {
139
+		return is_array($this->data[$field][$index]);
140 140
 	}
141 141
 
142 142
 	/**
@@ -148,8 +148,8 @@  discard block
 block discarded – undo
148 148
 	 * @param string $rule
149 149
 	 * @return bool
150 150
 	 */
151
-	protected function string_has_params( $rule ) {
152
-		return strpos( $rule, ':' );
151
+	protected function string_has_params($rule) {
152
+		return strpos($rule, ':');
153 153
 	}
154 154
 
155 155
 	/**
@@ -162,20 +162,20 @@  discard block
 block discarded – undo
162 162
 	 * @param array $rules
163 163
 	 * @return array
164 164
 	 */
165
-	protected function parse_rules( array $rules ) {
165
+	protected function parse_rules(array $rules) {
166 166
 		// WIP - works, but confusing - simplify or breakdown into small methods
167 167
 		$parsed = array();
168
-		$this->split_rules( $rules );
169
-		foreach( $rules as $field => $ruleset ) {
170
-			$parsed[ $field ] = array_map( function( $rule ) {
171
-				if ( $this->string_has_params( $rule ) ) {
168
+		$this->split_rules($rules);
169
+		foreach ($rules as $field => $ruleset) {
170
+			$parsed[$field] = array_map(function($rule) {
171
+				if ($this->string_has_params($rule)) {
172 172
 					return array(
173
-						'rule' => $this->extract_name( $rule ),
174
-						'params' => explode( ',', $this->extract_params( $rule ) )
173
+						'rule' => $this->extract_name($rule),
174
+						'params' => explode(',', $this->extract_params($rule))
175 175
 					);
176 176
 				}
177 177
 				return $rule;
178
-			}, $ruleset );
178
+			}, $ruleset);
179 179
 		}
180 180
 		return $parsed;
181 181
 	}
@@ -190,14 +190,14 @@  discard block
 block discarded – undo
190 190
 	 * @return array
191 191
 	 */
192 192
 	protected function remove_params() {
193
-		return array_map( function( $item ) {
194
-			foreach( $item as $rule ) {
195
-				if( $rule !== 'optional' ) {
196
-					$rules[] = ( is_string( $rule ) ) ? $rule : $rule['rule'];
193
+		return array_map(function($item) {
194
+			foreach ($item as $rule) {
195
+				if ($rule !== 'optional') {
196
+					$rules[] = (is_string($rule)) ? $rule : $rule['rule'];
197 197
 				}
198 198
 			}
199 199
 			return $rules;
200
-		}, $this->data );
200
+		}, $this->data);
201 201
 	}
202 202
 
203 203
 	/**
@@ -208,10 +208,10 @@  discard block
 block discarded – undo
208 208
 	 *
209 209
 	 * @param array $rules
210 210
 	 */
211
-	protected function split_rules( array &$rules ) {
211
+	protected function split_rules(array &$rules) {
212 212
 		// perhaps the $rules array structure should be validated here?...
213
-		$rules = array_map( function( $item ) {
214
-			return explode( '|', $item );
215
-		}, $rules );
213
+		$rules = array_map(function($item) {
214
+			return explode('|', $item);
215
+		}, $rules);
216 216
 	}
217 217
 }
Please login to merge, or discard this patch.
src/Contract/ValidateInterface.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 namespace WFV\Contract;
3
-defined( 'ABSPATH' ) || die();
3
+defined('ABSPATH') || die();
4 4
 
5 5
 
6 6
 /**
@@ -14,5 +14,5 @@  discard block
 block discarded – undo
14 14
 	/**
15 15
 	 * @return bool
16 16
 	 */
17
-	public function validate( $input = null, $optional = false );
17
+	public function validate($input = null, $optional = false);
18 18
 }
Please login to merge, or discard this patch.