Passed
Push — master ( ed8579...f866b8 )
by Paul
05:30
created
plugin/Modules/Html/Settings.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 	 */
36 36
 	protected function getFieldDefault( array $field )
37 37
 	{
38
-		return isset( $field['default'] )
38
+		return isset($field['default'])
39 39
 			? $field['default']
40 40
 			: '';
41 41
 	}
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
 	 */
46 46
 	protected function getSettingFields( $path )
47 47
 	{
48
-		return array_filter( $this->settings, function( $key ) use( $path ) {
48
+		return array_filter( $this->settings, function( $key ) use($path) {
49 49
 			return glsr( Helper::class )->startsWith( $path, $key );
50 50
 		}, ARRAY_FILTER_USE_KEY );
51 51
 	}
@@ -60,8 +60,8 @@  discard block
 block discarded – undo
60 60
 			$field = wp_parse_args( $field, [
61 61
 				'is_setting' => true,
62 62
 				'name' => $name,
63
-			]);
64
-			$rows.= new Field( $this->normalize( $field ));
63
+			] );
64
+			$rows .= new Field( $this->normalize( $field ) );
65 65
 		}
66 66
 		return $rows;
67 67
 	}
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 	 */
73 73
 	protected function getTemplateData( $id )
74 74
 	{
75
-		$fields = $this->getSettingFields( $this->normalizeSettingPath( $id ));
75
+		$fields = $this->getSettingFields( $this->normalizeSettingPath( $id ) );
76 76
 		return [
77 77
 			'context' => [
78 78
 				'rows' => $this->getSettingRows( $fields ),
@@ -86,12 +86,12 @@  discard block
 block discarded – undo
86 86
 	 */
87 87
 	protected function getTemplateDataForAddons( $id )
88 88
 	{
89
-		$fields = $this->getSettingFields( $this->normalizeSettingPath( $id ));
89
+		$fields = $this->getSettingFields( $this->normalizeSettingPath( $id ) );
90 90
 		$settings = glsr( Helper::class )->convertDotNotationArray( $fields );
91 91
 		$settingKeys = array_keys( $settings['settings']['addons'] );
92 92
 		$results = [];
93 93
 		foreach( $settingKeys as $key ) {
94
-			$addonFields = array_filter( $fields, function( $path ) use( $key ) {
94
+			$addonFields = array_filter( $fields, function( $path ) use($key) {
95 95
 				return glsr( Helper::class )->startsWith( 'settings.addons.'.$key, $path );
96 96
 			}, ARRAY_FILTER_USE_KEY );
97 97
 			$results[$key] = $this->getSettingRows( $addonFields );
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
 	protected function getTemplateDataForTranslations()
108 108
 	{
109 109
 		$translations = glsr( Translation::class )->renderAll();
110
-		$class = empty( $translations )
110
+		$class = empty($translations)
111 111
 			? 'glsr-hidden'
112 112
 			: '';
113 113
 		return [
@@ -130,9 +130,9 @@  discard block
 block discarded – undo
130 130
 			$path,
131 131
 			glsr( Helper::class )->getPathValue( $path, glsr()->defaults )
132 132
 		);
133
-		if( is_array( $expectedValue )) {
133
+		if( is_array( $expectedValue ) ) {
134 134
 			return is_array( $optionValue )
135
-				? count( array_intersect( $optionValue, $expectedValue )) === 0
135
+				? count( array_intersect( $optionValue, $expectedValue ) ) === 0
136 136
 				: !in_array( $optionValue, $expectedValue );
137 137
 		}
138 138
 		return $optionValue != $expectedValue;
@@ -143,10 +143,10 @@  discard block
 block discarded – undo
143 143
 	 */
144 144
 	protected function isMultiDependency( $path )
145 145
 	{
146
-		if( isset( $this->settings[$path] )) {
146
+		if( isset($this->settings[$path]) ) {
147 147
 			$field = $this->settings[$path];
148
-			return ( $field['type'] == 'checkbox' && !empty( $field['options'] ))
149
-				|| !empty( $field['multiple'] );
148
+			return ($field['type'] == 'checkbox' && !empty($field['options']))
149
+				|| !empty($field['multiple']);
150 150
 		}
151 151
 		return false;
152 152
 	}
@@ -167,17 +167,17 @@  discard block
 block discarded – undo
167 167
 	 */
168 168
 	protected function normalizeDependsOn( array $field )
169 169
 	{
170
-		if( !empty( $field['depends_on'] ) && is_array( $field['depends_on'] )) {
170
+		if( !empty($field['depends_on']) && is_array( $field['depends_on'] ) ) {
171 171
 			$path = key( $field['depends_on'] );
172 172
 			$expectedValue = $field['depends_on'][$path];
173 173
 			$fieldName = glsr( Helper::class )->convertPathToName( $path, OptionManager::databaseKey() );
174
-			if( $this->isMultiDependency( $path )) {
175
-				$fieldName.= '[]';
174
+			if( $this->isMultiDependency( $path ) ) {
175
+				$fieldName .= '[]';
176 176
 			}
177
-			$field['data-depends'] = json_encode([
177
+			$field['data-depends'] = json_encode( [
178 178
 				'name' => $fieldName,
179 179
 				'value' => $expectedValue,
180
-			], JSON_HEX_APOS|JSON_HEX_QUOT );
180
+			], JSON_HEX_APOS | JSON_HEX_QUOT );
181 181
 			$field['is_hidden'] = $this->isFieldHidden( $path, $expectedValue );
182 182
 		}
183 183
 		return $field;
@@ -188,9 +188,9 @@  discard block
 block discarded – undo
188 188
 	 */
189 189
 	protected function normalizeLabelAndLegend( array $field )
190 190
 	{
191
-		if( !empty( $field['label'] )) {
191
+		if( !empty($field['label']) ) {
192 192
 			$field['legend'] = $field['label'];
193
-			unset( $field['label'] );
193
+			unset($field['label']);
194 194
 		}
195 195
 		else {
196 196
 			$field['is_valid'] = false;
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
 	 */
205 205
 	protected function normalizeValue( array $field )
206 206
 	{
207
-		if( !isset( $field['value'] )) {
207
+		if( !isset($field['value']) ) {
208 208
 			$field['value'] = glsr( OptionManager::class )->get(
209 209
 				$field['name'],
210 210
 				$this->getFieldDefault( $field )
Please login to merge, or discard this patch.
plugin/Handlers/RegisterTinymcePopups.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -14,14 +14,14 @@
 block discarded – undo
14 14
 	{
15 15
 		foreach( $command->popups as $slug => $label ) {
16 16
 			$buttonClass = glsr( Helper::class )->buildClassName( $slug.'-popup', 'Shortcodes' );
17
-			if( !class_exists( $buttonClass )) {
18
-				glsr_log()->error( sprintf( 'Class missing (%s)', $buttonClass ));
17
+			if( !class_exists( $buttonClass ) ) {
18
+				glsr_log()->error( sprintf( 'Class missing (%s)', $buttonClass ) );
19 19
 				continue;
20 20
 			}
21 21
 			$shortcode = glsr( $buttonClass )->register( $slug, [
22 22
 				'label' => $label,
23 23
 				'title' => $label,
24
-			]);
24
+			] );
25 25
 			glsr()->mceShortcodes[$slug] = $shortcode->properties;
26 26
 		}
27 27
 	}
Please login to merge, or discard this patch.
plugin/Commands/CreateReview.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -29,23 +29,23 @@  discard block
 block discarded – undo
29 29
 	public function __construct( $input )
30 30
 	{
31 31
 		$this->request = $input;
32
-		$this->ajax_request = isset( $input['ajax_request'] );
32
+		$this->ajax_request = isset($input['ajax_request']);
33 33
 		$this->assigned_to = $this->getNumeric( 'assign_to' );
34
-		$this->author = sanitize_text_field( $this->get( 'name' ));
35
-		$this->avatar = get_avatar_url( $this->get( 'email' ));
36
-		$this->blacklisted = isset( $input['blacklisted'] );
37
-		$this->category = sanitize_key( $this->get( 'category' ));
38
-		$this->content = sanitize_textarea_field( $this->get( 'content' ));
34
+		$this->author = sanitize_text_field( $this->get( 'name' ) );
35
+		$this->avatar = get_avatar_url( $this->get( 'email' ) );
36
+		$this->blacklisted = isset($input['blacklisted']);
37
+		$this->category = sanitize_key( $this->get( 'category' ) );
38
+		$this->content = sanitize_textarea_field( $this->get( 'content' ) );
39 39
 		$this->custom = $this->getCustom();
40 40
 		$this->date = $this->getDate( 'date' );
41
-		$this->email = sanitize_email( $this->get( 'email' ));
42
-		$this->form_id = sanitize_key( $this->get( 'form_id' ));
41
+		$this->email = sanitize_email( $this->get( 'email' ) );
42
+		$this->form_id = sanitize_key( $this->get( 'form_id' ) );
43 43
 		$this->ip_address = $this->get( 'ip_address' );
44
-		$this->post_id = intval( $this->get( 'post_id' ));
45
-		$this->rating = intval( $this->get( 'rating' ));
44
+		$this->post_id = intval( $this->get( 'post_id' ) );
45
+		$this->rating = intval( $this->get( 'rating' ) );
46 46
 		$this->referer = $this->get( 'referer' );
47
-		$this->terms = !empty( $input['terms'] );
48
-		$this->title = sanitize_text_field( $this->get( 'title' ));
47
+		$this->terms = !empty($input['terms']);
48
+		$this->title = sanitize_text_field( $this->get( 'title' ) );
49 49
 	}
50 50
 
51 51
 	/**
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 	 */
55 55
 	protected function get( $key )
56 56
 	{
57
-		return isset( $this->request[$key] )
57
+		return isset($this->request[$key])
58 58
 			? (string)$this->request[$key]
59 59
 			: '';
60 60
 	}
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 		];
72 72
 		$custom = $this->request;
73 73
 		foreach( $unset as $value ) {
74
-			unset( $custom[$value] );
74
+			unset($custom[$value]);
75 75
 		}
76 76
 		return $custom;
77 77
 	}
@@ -82,11 +82,11 @@  discard block
 block discarded – undo
82 82
 	 */
83 83
 	protected function getDate( $key )
84 84
 	{
85
-		$date = strtotime( $this->get( $key ));
85
+		$date = strtotime( $this->get( $key ) );
86 86
 		if( $date === false ) {
87 87
 			$date = time();
88 88
 		}
89
-		return get_date_from_gmt( gmdate( 'Y-m-d H:i:s', $date ));
89
+		return get_date_from_gmt( gmdate( 'Y-m-d H:i:s', $date ) );
90 90
 	}
91 91
 
92 92
 	/**
Please login to merge, or discard this patch.
plugin/Helper.php 2 patches
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
 	{
17 17
 		$className = $this->camelCase( $name );
18 18
 		$path = ltrim( str_replace( __NAMESPACE__, '', $path ), '\\' );
19
-		return !empty( $path )
19
+		return !empty($path)
20 20
 			? __NAMESPACE__.'\\'.$path.'\\'.$className
21 21
 			: $className;
22 22
 	}
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 	 */
29 29
 	public function buildMethodName( $name, $prefix = '' )
30 30
 	{
31
-		return lcfirst( $prefix.$this->buildClassName( $name ));
31
+		return lcfirst( $prefix.$this->buildClassName( $name ) );
32 32
 	}
33 33
 
34 34
 	/**
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 	 */
38 38
 	public function buildPropertyName( $name )
39 39
 	{
40
-		return lcfirst( $this->buildClassName( $name ));
40
+		return lcfirst( $this->buildClassName( $name ) );
41 41
 	}
42 42
 
43 43
 	/**
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 	 */
47 47
 	public function camelCase( $string )
48 48
 	{
49
-		$string = ucwords( str_replace( ['-', '_'], ' ', trim( $string )));
49
+		$string = ucwords( str_replace( ['-', '_'], ' ', trim( $string ) ) );
50 50
 		return str_replace( ' ', '', $string );
51 51
 	}
52 52
 
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 	 */
79 79
 	public function convertPathToId( $path, $prefix = '' )
80 80
 	{
81
-		return str_replace( ['[', ']'], ['-', ''], $this->convertPathToName( $path, $prefix ));
81
+		return str_replace( ['[', ']'], ['-', ''], $this->convertPathToName( $path, $prefix ) );
82 82
 	}
83 83
 
84 84
 	/**
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 	{
90 90
 		$levels = explode( '.', $path );
91 91
 		return array_reduce( $levels, function( $result, $value ) {
92
-			return $result.= '['.$value.']';
92
+			return $result .= '['.$value.']';
93 93
 		}, $prefix );
94 94
 	}
95 95
 
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
 	 */
101 101
 	public function convertStringToArray( $string, $callback = null )
102 102
 	{
103
-		$array = array_map( 'trim', explode( ',', $string ));
103
+		$array = array_map( 'trim', explode( ',', $string ) );
104 104
 		return $callback
105 105
 			? array_filter( $array, $callback )
106 106
 			: array_filter( $array );
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
 	 */
113 113
 	public function dashCase( $string )
114 114
 	{
115
-		return str_replace( '_', '-', $this->snakeCase( $string ));
115
+		return str_replace( '_', '-', $this->snakeCase( $string ) );
116 116
 	}
117 117
 
118 118
 	/**
@@ -134,11 +134,11 @@  discard block
 block discarded – undo
134 134
 	 */
135 135
 	public function filterInput( $key, array $request = [] )
136 136
 	{
137
-		if( isset( $request[$key] )) {
137
+		if( isset($request[$key]) ) {
138 138
 			return $request[$key];
139 139
 		}
140 140
 		$variable = filter_input( INPUT_POST, $key );
141
-		if( is_null( $variable ) && isset( $_POST[$key] )) {
141
+		if( is_null( $variable ) && isset($_POST[$key]) ) {
142 142
 			$variable = $_POST[$key];
143 143
 		}
144 144
 		return $variable;
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
 	public function filterInputArray( $key )
152 152
 	{
153 153
 		$variable = filter_input( INPUT_POST, $key, FILTER_DEFAULT, FILTER_REQUIRE_ARRAY );
154
-		if( empty( $variable ) && !empty( $_POST[$key] ) && is_array( $_POST[$key] )) {
154
+		if( empty($variable) && !empty($_POST[$key]) && is_array( $_POST[$key] ) ) {
155 155
 			$variable = $_POST[$key];
156 156
 		}
157 157
 		return (array)$variable;
@@ -167,13 +167,13 @@  discard block
 block discarded – undo
167 167
 		$result = [];
168 168
 		foreach( $array as $key => $value ) {
169 169
 			$newKey = ltrim( $prefix.'.'.$key, '.' );
170
-			if( $this->isIndexedFlatArray( $value )) {
170
+			if( $this->isIndexedFlatArray( $value ) ) {
171 171
 				if( $flattenValue ) {
172 172
 					$value = '['.implode( ', ', $value ).']';
173 173
 				}
174 174
 			}
175
-			else if( is_array( $value )) {
176
-				$result = array_merge( $result, $this->flattenArray( $value, $flattenValue, $newKey ));
175
+			else if( is_array( $value ) ) {
176
+				$result = array_merge( $result, $this->flattenArray( $value, $flattenValue, $newKey ) );
177 177
 				continue;
178 178
 			}
179 179
 			$result[$newKey] = $value;
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
 				Whip::IPV4 => $cloudflareIps['v4'],
193 193
 				Whip::IPV6 => $cloudflareIps['v6'],
194 194
 			],
195
-		]))->getValidIpAddress();
195
+		] ))->getValidIpAddress();
196 196
 	}
197 197
 
198 198
 	/**
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
 	{
206 206
 		$keys = explode( '.', $path );
207 207
 		foreach( $keys as $key ) {
208
-			if( !isset( $values[$key] )) {
208
+			if( !isset($values[$key]) ) {
209 209
 				return $fallback;
210 210
 			}
211 211
 			$values = $values[$key];
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
 	 */
220 220
 	public function isIndexedArray( $array )
221 221
 	{
222
-		if( !is_array( $array )) {
222
+		if( !is_array( $array ) ) {
223 223
 			return false;
224 224
 		}
225 225
 		$current = 0;
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
 	 */
239 239
 	public function isIndexedFlatArray( $array )
240 240
 	{
241
-		if( !is_array( $array ) || array_filter( $array, 'is_array' )) {
241
+		if( !is_array( $array ) || array_filter( $array, 'is_array' ) ) {
242 242
 			return false;
243 243
 		}
244 244
 		return $this->isIndexedArray( $array );
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
 	 */
252 252
 	public function prefixString( $string, $prefix = '' )
253 253
 	{
254
-		return $prefix.str_replace( $prefix, '', trim( $string ));
254
+		return $prefix.str_replace( $prefix, '', trim( $string ) );
255 255
 	}
256 256
 
257 257
 	/**
@@ -276,7 +276,7 @@  discard block
 block discarded – undo
276 276
 	 */
277 277
 	public function removePrefix( $prefix, $text ) {
278 278
 		return 0 === strpos( $text, $prefix )
279
-			? substr( $text, strlen( $prefix ))
279
+			? substr( $text, strlen( $prefix ) )
280 280
 			: $text;
281 281
 	}
282 282
 
@@ -307,7 +307,7 @@  discard block
 block discarded – undo
307 307
 	 */
308 308
 	public function snakeCase( $string )
309 309
 	{
310
-		if( !ctype_lower( $string )) {
310
+		if( !ctype_lower( $string ) ) {
311 311
 			$string = preg_replace( '/\s+/u', '', $string );
312 312
 			$string = preg_replace( '/(.)(?=[A-Z])/u', '$1_', $string );
313 313
 			$string = mb_strtolower( $string, 'UTF-8' );
@@ -322,6 +322,6 @@  discard block
 block discarded – undo
322 322
 	 */
323 323
 	public function startsWith( $needle, $haystack )
324 324
 	{
325
-		return substr( $haystack, 0, strlen( $needle )) === $needle;
325
+		return substr( $haystack, 0, strlen( $needle ) ) === $needle;
326 326
 	}
327 327
 }
Please login to merge, or discard this patch.
Braces   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -261,7 +261,9 @@  discard block
 block discarded – undo
261 261
 	{
262 262
 		$result = [];
263 263
 		foreach( $array as $key => $value ) {
264
-			if( !$value )continue;
264
+			if( !$value ) {
265
+				continue;
266
+			}
265 267
 			$result[$key] = is_array( $value )
266 268
 				? $this->removeEmptyArrayValues( $value )
267 269
 				: $value;
@@ -274,7 +276,8 @@  discard block
 block discarded – undo
274 276
 	 * @param string $text
275 277
 	 * @return string
276 278
 	 */
277
-	public function removePrefix( $prefix, $text ) {
279
+	public function removePrefix( $prefix, $text )
280
+	{
278 281
 		return 0 === strpos( $text, $prefix )
279 282
 			? substr( $text, strlen( $prefix ))
280 283
 			: $text;
Please login to merge, or discard this patch.
plugin/Modules/Style.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -50,12 +50,12 @@  discard block
 block discarded – undo
50 50
 			'templates/form/submit-button',
51 51
 			'templates/reviews-form',
52 52
 		];
53
-		if( !preg_match( '('.implode( '|', $styledViews ).')', $view )) {
53
+		if( !preg_match( '('.implode( '|', $styledViews ).')', $view ) ) {
54 54
 			return $view;
55 55
 		}
56 56
 		$views = $this->generatePossibleViews( $view );
57 57
 		foreach( $views as $possibleView ) {
58
-			if( !file_exists( glsr()->path( $possibleView.'.php' )))continue;
58
+			if( !file_exists( glsr()->path( $possibleView.'.php' ) ) )continue;
59 59
 			return glsr( Helper::class )->removePrefix( 'views/', $possibleView );
60 60
 		}
61 61
 		return $view;
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
 	 */
89 89
 	public function modifyField( Builder $instance )
90 90
 	{
91
-		if( !$this->isPublicInstance( $instance ) || empty( array_filter( $this->fields )))return;
91
+		if( !$this->isPublicInstance( $instance ) || empty(array_filter( $this->fields )) )return;
92 92
 		call_user_func_array( [$this, 'customize'], [&$instance] );
93 93
 	}
94 94
 
@@ -105,9 +105,9 @@  discard block
 block discarded – undo
105 105
 	 */
106 106
 	protected function customize( Builder $instance )
107 107
 	{
108
-		$args = wp_parse_args( $instance->args, array_fill_keys( ['class', 'type'], '' ));
108
+		$args = wp_parse_args( $instance->args, array_fill_keys( ['class', 'type'], '' ) );
109 109
 		$key = $instance->tag.'_'.$args['type'];
110
-		$classes = !isset( $this->fields[$key] )
110
+		$classes = !isset($this->fields[$key])
111 111
 			? $this->fields[$instance->tag]
112 112
 			: $this->fields[$key];
113 113
 		$instance->args['class'] = trim( $args['class'].' '.$classes );
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
 		$args = wp_parse_args( $instance->args, [
142 142
 			'is_public' => false,
143 143
 			'is_raw' => false,
144
-		]);
144
+		] );
145 145
 		if( is_admin() || !$args['is_public'] || $args['is_raw'] ) {
146 146
 			return false;
147 147
 		}
Please login to merge, or discard this patch.
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -55,7 +55,9 @@  discard block
 block discarded – undo
55 55
 		}
56 56
 		$views = $this->generatePossibleViews( $view );
57 57
 		foreach( $views as $possibleView ) {
58
-			if( !file_exists( glsr()->path( $possibleView.'.php' )))continue;
58
+			if( !file_exists( glsr()->path( $possibleView.'.php' ))) {
59
+				continue;
60
+			}
59 61
 			return glsr( Helper::class )->removePrefix( 'views/', $possibleView );
60 62
 		}
61 63
 		return $view;
@@ -88,7 +90,9 @@  discard block
 block discarded – undo
88 90
 	 */
89 91
 	public function modifyField( Builder $instance )
90 92
 	{
91
-		if( !$this->isPublicInstance( $instance ) || empty( array_filter( $this->fields )))return;
93
+		if( !$this->isPublicInstance( $instance ) || empty( array_filter( $this->fields ))) {
94
+			return;
95
+		}
92 96
 		call_user_func_array( [$this, 'customize'], [&$instance] );
93 97
 	}
94 98
 
Please login to merge, or discard this patch.