Completed
Push — master ( ea6a8c...d2d9ba )
by Maciej
8s
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/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/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.
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/Agent/InspectionAgent.php 1 patch
Spacing   +7 added lines, -7 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
 /**
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 	 *
27 27
 	 * @param string $action
28 28
 	 */
29
-	public function __construct( $action ) {
29
+	public function __construct($action) {
30 30
 		$this->action = $action;
31 31
 	}
32 32
 
@@ -40,8 +40,8 @@  discard block
 block discarded – undo
40 40
 	 * @return bool
41 41
 	 */
42 42
 	public function safe_submit() {
43
-		if( $this->submit_has_action() ) {
44
-			return ( $_POST['action'] === $this->action ) ? $this->nonce() : false;
43
+		if ($this->submit_has_action()) {
44
+			return ($_POST['action'] === $this->action) ? $this->nonce() : false;
45 45
 		}
46 46
 		return false;
47 47
 	}
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 	 * @return bool
55 55
 	 */
56 56
 	private function submit_has_action() {
57
-		return isset( $_POST['action'] );
57
+		return isset($_POST['action']);
58 58
 	}
59 59
 
60 60
 	/**
@@ -66,8 +66,8 @@  discard block
 block discarded – undo
66 66
 	 * @return bool
67 67
 	 */
68 68
 	private function nonce() {
69
-		$nonce = $_REQUEST[ $this->action.'_token' ];
70
-		return ( wp_verify_nonce( $nonce, $this->action ) ) ? true : false;
69
+		$nonce = $_REQUEST[$this->action.'_token'];
70
+		return (wp_verify_nonce($nonce, $this->action)) ? true : false;
71 71
 	}
72 72
 
73 73
 }
Please login to merge, or discard this patch.
src/Collection/InputCollection.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\Collection;
3
-defined( 'ABSPATH' ) || die();
3
+defined('ABSPATH') || die();
4 4
 
5 5
 use WFV\Abstraction\Collectable;
6 6
 use WFV\Agent\InspectionAgent;
@@ -29,9 +29,9 @@  discard block
 block discarded – undo
29 29
 	 * @param array $data
30 30
 	 * @param bool $trim
31 31
 	 */
32
-	public function __construct( InspectionAgent $guard, $trim = true ) {
32
+	public function __construct(InspectionAgent $guard, $trim = true) {
33 33
 		$this->guard = $guard;
34
-		$this->populate( $trim );
34
+		$this->populate($trim);
35 35
 	}
36 36
 
37 37
 	/**
@@ -42,8 +42,8 @@  discard block
 block discarded – undo
42 42
 	 * @param bool $neat With or without token and action attributes.
43 43
 	 * @return array
44 44
 	 */
45
-	public function get_array( $neat = true ) {
46
-		return ( $neat ) ? $this->neat_array() : $this->data;
45
+	public function get_array($neat = true) {
46
+		return ($neat) ? $this->neat_array() : $this->data;
47 47
 	}
48 48
 
49 49
 	/**
@@ -56,8 +56,8 @@  discard block
 block discarded – undo
56 56
 	 */
57 57
 	protected function neat_array() {
58 58
 		$input = $this->data;
59
-		unset( $input[ $input['action'] .'_token'] );
60
-		unset( $input['action'] );
59
+		unset($input[$input['action'].'_token']);
60
+		unset($input['action']);
61 61
 		return $input;
62 62
 	}
63 63
 
@@ -68,12 +68,12 @@  discard block
 block discarded – undo
68 68
 	 * @access protected
69 69
 	 *
70 70
 	 */
71
-	protected function populate( $trim ) {
72
-		if( $this->guard->safe_submit() ) {
73
-			$data = $this->transform_array_leafs( $_POST, 'stripslashes' );
71
+	protected function populate($trim) {
72
+		if ($this->guard->safe_submit()) {
73
+			$data = $this->transform_array_leafs($_POST, 'stripslashes');
74 74
 
75
-			$this->data = ( $trim )
76
-				? $this->transform_array_leafs( $data, 'trim' )
75
+			$this->data = ($trim)
76
+				? $this->transform_array_leafs($data, 'trim')
77 77
 				: $data;
78 78
 		}
79 79
 	}
Please login to merge, or discard this patch.
src/RuleFactory.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;
3
-defined( 'ABSPATH' ) || die();
3
+defined('ABSPATH') || die();
4 4
 
5 5
 use WFV\Rules;
6 6
 
@@ -28,12 +28,12 @@  discard block
 block discarded – undo
28 28
 	 * @param string $rule
29 29
 	 * @return ValidateInterface|bool
30 30
 	 */
31
-	public function get( $rule ) {
32
-		if ( !isset( $this->pool[ $rule ] ) ) {
33
-			$class = $this->class_name( $rule );
34
-			$this->pool[ $rule ] = new $class();
31
+	public function get($rule) {
32
+		if (!isset($this->pool[$rule])) {
33
+			$class = $this->class_name($rule);
34
+			$this->pool[$rule] = new $class();
35 35
 		}
36
-		return $this->pool[ $rule ];
36
+		return $this->pool[$rule];
37 37
 	}
38 38
 
39 39
 	/**
@@ -45,8 +45,8 @@  discard block
 block discarded – undo
45 45
 	 * @param string $rule
46 46
 	 * @return string
47 47
 	 */
48
-	protected function class_name( $rule ){
49
-		$name = str_replace(' ', '', ucwords( str_replace('_', ' ', $rule ) ) );
48
+	protected function class_name($rule) {
49
+		$name = str_replace(' ', '', ucwords(str_replace('_', ' ', $rule)));
50 50
 		return 'WFV\Rules\\'.$name;
51 51
 	}
52 52
 }
Please login to merge, or discard this patch.
src/Rules/Boolean.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\Rules;
3
-defined( 'ABSPATH' ) || die();
3
+defined('ABSPATH') || die();
4 4
 
5 5
 use WFV\Rules\AbstractRule;
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()->boolVal() )->validate( $input )
39
-			: $v->boolVal()->validate( $input );
37
+		return ($optional)
38
+			? $v->optional($v->create()->boolVal())->validate($input)
39
+			: $v->boolVal()->validate($input);
40 40
 	}
41 41
 }
Please login to merge, or discard this patch.
src/Rules/AlphaDash.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\Rules;
3
-defined( 'ABSPATH' ) || die();
3
+defined('ABSPATH') || die();
4 4
 
5 5
 use WFV\Rules\AbstractRule;
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()->alpha('-_') )->validate( $input )
39
-			: $v->alpha('-_')->validate( $input );
37
+		return ($optional)
38
+			? $v->optional($v->create()->alpha('-_'))->validate($input)
39
+			: $v->alpha('-_')->validate($input);
40 40
 	}
41 41
 }
Please login to merge, or discard this patch.