Completed
Pull Request — master (#138)
by Maciej
02:15
created
src/Abstraction/Composable.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\Abstraction;
3
-defined( 'ABSPATH' ) || die();
3
+defined('ABSPATH') || die();
4 4
 
5 5
 /**
6 6
  *
@@ -36,8 +36,8 @@  discard block
 block discarded – undo
36 36
 	 * @param string $name
37 37
 	 * @param class $collection
38 38
 	 */
39
-	protected function add_collection( $name, $collection ) {
40
-		$this->collection[ $name ] = $collection;
39
+	protected function add_collection($name, $collection) {
40
+		$this->collection[$name] = $collection;
41 41
 	}
42 42
 
43 43
 	/**
@@ -48,8 +48,8 @@  discard block
 block discarded – undo
48 48
 	 *
49 49
 	 * @param string $component Key indentifier.
50 50
 	 */
51
-	protected function utilize( $component ) {
52
-		return $this->collection[ $component ];
51
+	protected function utilize($component) {
52
+		return $this->collection[$component];
53 53
 	}
54 54
 
55 55
 	/**
@@ -60,9 +60,9 @@  discard block
 block discarded – undo
60 60
 	 *
61 61
 	 * @param array $collections
62 62
 	 */
63
-	protected function install( array $collections ) {
64
-		foreach( $collections as $name => $collection ) {
65
-			$this->add_collection( $name, $collection );
63
+	protected function install(array $collections) {
64
+		foreach ($collections as $name => $collection) {
65
+			$this->add_collection($name, $collection);
66 66
 		}
67 67
 	}
68 68
 }
Please login to merge, or discard this patch.
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/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 1 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/Abstraction/Collectable.php 1 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/FormComposite.php 2 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -4,7 +4,6 @@
 block discarded – undo
4 4
 
5 5
 use WFV\Abstraction\Composable;
6 6
 use WFV\Artisan\FormArtisan;
7
-use WFV\Contract\ValidateInterface;
8 7
 use WFV\Factory\ValidatorFactory;
9 8
 
10 9
 /**
Please login to merge, or discard this patch.
Spacing   +32 added lines, -32 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\Abstraction\Composable;
6 6
 use WFV\Artisan\FormArtisan;
@@ -31,9 +31,9 @@  discard block
 block discarded – undo
31 31
 	 * @param ArtisanInterface $builder
32 32
 	 * @param string $action
33 33
 	 */
34
-	public function __construct( FormArtisan $builder, $action ) {
34
+	public function __construct(FormArtisan $builder, $action) {
35 35
 		$this->alias = $action;
36
-		$this->install( $builder->collection );
36
+		$this->install($builder->collection);
37 37
 		$this->validator = $builder->validator;
38 38
 	}
39 39
 
@@ -46,8 +46,8 @@  discard block
 block discarded – undo
46 46
 	 * @param string $value Value to compare against.
47 47
 	 * @return string|null
48 48
 	 */
49
-	public function checked_if( $field = null, $value = null ) {
50
-		return $this->string_or_null( 'checked', $field, $value );
49
+	public function checked_if($field = null, $value = null) {
50
+		return $this->string_or_null('checked', $field, $value);
51 51
 	}
52 52
 
53 53
 	/**
@@ -61,8 +61,8 @@  discard block
 block discarded – undo
61 61
 	 * @param callable (optional) $callback
62 62
 	 * @return string
63 63
 	 */
64
-	public function display( $field = null, callable $callback = null ) {
65
-		echo $input = $this->utilize('input')->escape( $field );
64
+	public function display($field = null, callable $callback = null) {
65
+		echo $input = $this->utilize('input')->escape($field);
66 66
 		return $input;
67 67
 	}
68 68
 
@@ -100,10 +100,10 @@  discard block
 block discarded – undo
100 100
 	 */
101 101
 	public function is_valid() {
102 102
 		$is_valid = $this->validator->is_valid();
103
-		if( false === $is_valid ) {
104
-			$this->utilize('errors')->set_errors( $this->validator->errors() );
103
+		if (false === $is_valid) {
104
+			$this->utilize('errors')->set_errors($this->validator->errors());
105 105
 		}
106
-		$this->trigger_post_validate_action( $is_valid );
106
+		$this->trigger_post_validate_action($is_valid);
107 107
 		return $is_valid;
108 108
 	}
109 109
 
@@ -127,8 +127,8 @@  discard block
 block discarded – undo
127 127
 	 * @param string $value Value to compare against.
128 128
 	 * @return string|null
129 129
 	 */
130
-	public function selected_if( $field = null, $value = null ) {
131
-		return $this->string_or_null( 'selected', $field, $value );
130
+	public function selected_if($field = null, $value = null) {
131
+		return $this->string_or_null('selected', $field, $value);
132 132
 	}
133 133
 
134 134
 	/**
@@ -140,9 +140,9 @@  discard block
 block discarded – undo
140 140
 	 */
141 141
 	public function token_fields() {
142 142
 		// TODO - Move markup into something - perhaps a renderable interface?
143
-		$token_name = $this->alias . '_token';
144
-		echo $nonce_field = wp_nonce_field( $this->alias, $token_name, false, false );
145
-		echo $action_field = '<input type="hidden" name="action" value="'. $this->alias .'">';
143
+		$token_name = $this->alias.'_token';
144
+		echo $nonce_field = wp_nonce_field($this->alias, $token_name, false, false);
145
+		echo $action_field = '<input type="hidden" name="action" value="'.$this->alias.'">';
146 146
 	}
147 147
 
148 148
 	/**
@@ -153,17 +153,17 @@  discard block
 block discarded – undo
153 153
 	 * @param ValidatorFactory $factory
154 154
 	 * @return self
155 155
 	 */
156
-	public function validate( ValidatorFactory $factory ) {
156
+	public function validate(ValidatorFactory $factory) {
157 157
 		$rule_collection = $this->utilize('rules');
158
-		$rules = $rule_collection->get_array( true );
158
+		$rules = $rule_collection->get_array(true);
159 159
 
160
-		foreach( $rules as $field => $ruleset ) {
161
-			$input = $this->field_value( $field );
162
-			$optional = $rule_collection->is_optional( $field );
160
+		foreach ($rules as $field => $ruleset) {
161
+			$input = $this->field_value($field);
162
+			$optional = $rule_collection->is_optional($field);
163 163
 
164
-			foreach( $ruleset as $index => $rule ) {
165
-				$params = $rule_collection->get_params( $field, $index );
166
-				$this->validator->validate( $factory->get( $rule ), $field, $input, $optional, $params );
164
+			foreach ($ruleset as $index => $rule) {
165
+				$params = $rule_collection->get_params($field, $index);
166
+				$this->validator->validate($factory->get($rule), $field, $input, $optional, $params);
167 167
 			}
168 168
 		}
169 169
 		return $this;
@@ -178,11 +178,11 @@  discard block
 block discarded – undo
178 178
 	 *
179 179
 	 * @param string $field
180 180
 	 */
181
-	protected function field_value( $field ) {
181
+	protected function field_value($field) {
182 182
 		$input = $this->utilize('input');
183
-		if( $input->has( $field ) ) {
184
-			$input = $input->get_array( false );
185
-			return $input[ $field ];
183
+		if ($input->has($field)) {
184
+			$input = $input->get_array(false);
185
+			return $input[$field];
186 186
 		}
187 187
 		return null;
188 188
 	}
@@ -198,8 +198,8 @@  discard block
 block discarded – undo
198 198
 	 * @param string (optional) $value
199 199
 	 * @return string|null
200 200
 	 */
201
-	protected function string_or_null( $response, $field = null, $value = null ) {
202
-		return ( $this->input( $field )->contains( $field, $value ) ) ? $response : null;
201
+	protected function string_or_null($response, $field = null, $value = null) {
202
+		return ($this->input($field)->contains($field, $value)) ? $response : null;
203 203
 	}
204 204
 
205 205
 	/**
@@ -210,8 +210,8 @@  discard block
 block discarded – undo
210 210
 	 *
211 211
 	 * @param bool $is_valid
212 212
 	 */
213
-	protected function trigger_post_validate_action( $is_valid = false ) {
214
-		$action = ( true === $is_valid ) ? $this->alias : $this->alias .'_fail';
215
-		do_action( $action, $this );
213
+	protected function trigger_post_validate_action($is_valid = false) {
214
+		$action = (true === $is_valid) ? $this->alias : $this->alias.'_fail';
215
+		do_action($action, $this);
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.