Passed
Push — master ( ccb079...7906b4 )
by Paul
04:39
created
plugin/Blocks/SiteReviewsSummaryBlock.php 2 patches
Indentation   +67 added lines, -67 removed lines patch added patch discarded remove patch
@@ -6,73 +6,73 @@
 block discarded – undo
6 6
 
7 7
 class SiteReviewsSummaryBlock extends BlockGenerator
8 8
 {
9
-    /**
10
-     * @return array
11
-     */
12
-    public function attributes()
13
-    {
14
-        return [
15
-            'assigned_to' => [
16
-                'default' => '',
17
-                'type' => 'string',
18
-            ],
19
-            'category' => [
20
-                'default' => '',
21
-                'type' => 'string',
22
-            ],
23
-            'className' => [
24
-                'default' => '',
25
-                'type' => 'string',
26
-            ],
27
-            'hide' => [
28
-                'default' => '',
29
-                'type' => 'string',
30
-            ],
31
-            'post_id' => [
32
-                'default' => '',
33
-                'type' => 'string',
34
-            ],
35
-            'rating' => [
36
-                'default' => '1',
37
-                'type' => 'number',
38
-            ],
39
-            'schema' => [
40
-                'default' => false,
41
-                'type' => 'boolean',
42
-            ],
43
-            'type' => [
44
-                'default' => 'local',
45
-                'type' => 'string',
46
-            ],
47
-        ];
48
-    }
9
+	/**
10
+	 * @return array
11
+	 */
12
+	public function attributes()
13
+	{
14
+		return [
15
+			'assigned_to' => [
16
+				'default' => '',
17
+				'type' => 'string',
18
+			],
19
+			'category' => [
20
+				'default' => '',
21
+				'type' => 'string',
22
+			],
23
+			'className' => [
24
+				'default' => '',
25
+				'type' => 'string',
26
+			],
27
+			'hide' => [
28
+				'default' => '',
29
+				'type' => 'string',
30
+			],
31
+			'post_id' => [
32
+				'default' => '',
33
+				'type' => 'string',
34
+			],
35
+			'rating' => [
36
+				'default' => '1',
37
+				'type' => 'number',
38
+			],
39
+			'schema' => [
40
+				'default' => false,
41
+				'type' => 'boolean',
42
+			],
43
+			'type' => [
44
+				'default' => 'local',
45
+				'type' => 'string',
46
+			],
47
+		];
48
+	}
49 49
 
50
-    /**
51
-     * @return string
52
-     */
53
-    public function render(array $attributes)
54
-    {
55
-        $attributes['class'] = $attributes['className'];
56
-        $shortcode = glsr(Shortcode::class);
57
-        if ('edit' == filter_input(INPUT_GET, 'context')) {
58
-            $attributes = $this->normalize($attributes);
59
-            $this->filterBlockClass();
60
-            if (!$this->hasVisibleFields($shortcode, $attributes)) {
61
-                $this->filterInterpolation();
62
-            }
63
-        }
64
-        return $shortcode->buildBlock($attributes);
65
-    }
50
+	/**
51
+	 * @return string
52
+	 */
53
+	public function render(array $attributes)
54
+	{
55
+		$attributes['class'] = $attributes['className'];
56
+		$shortcode = glsr(Shortcode::class);
57
+		if ('edit' == filter_input(INPUT_GET, 'context')) {
58
+			$attributes = $this->normalize($attributes);
59
+			$this->filterBlockClass();
60
+			if (!$this->hasVisibleFields($shortcode, $attributes)) {
61
+				$this->filterInterpolation();
62
+			}
63
+		}
64
+		return $shortcode->buildBlock($attributes);
65
+	}
66 66
 
67
-    /**
68
-     * @return void
69
-     */
70
-    protected function filterInterpolation()
71
-    {
72
-        add_filter('site-reviews/interpolate/reviews-summary', function ($context) {
73
-            $context['class'] = 'glsr-default glsr-block-disabled';
74
-            $context['text'] = __('You have hidden all of the fields for this block.', 'site-reviews');
75
-            return $context;
76
-        });
77
-    }
67
+	/**
68
+	 * @return void
69
+	 */
70
+	protected function filterInterpolation()
71
+	{
72
+		add_filter('site-reviews/interpolate/reviews-summary', function ($context) {
73
+			$context['class'] = 'glsr-default glsr-block-disabled';
74
+			$context['text'] = __('You have hidden all of the fields for this block.', 'site-reviews');
75
+			return $context;
76
+		});
77
+	}
78 78
 }
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -50,18 +50,18 @@  discard block
 block discarded – undo
50 50
     /**
51 51
      * @return string
52 52
      */
53
-    public function render(array $attributes)
53
+    public function render( array $attributes )
54 54
     {
55 55
         $attributes['class'] = $attributes['className'];
56
-        $shortcode = glsr(Shortcode::class);
57
-        if ('edit' == filter_input(INPUT_GET, 'context')) {
58
-            $attributes = $this->normalize($attributes);
56
+        $shortcode = glsr( Shortcode::class );
57
+        if( 'edit' == filter_input( INPUT_GET, 'context' ) ) {
58
+            $attributes = $this->normalize( $attributes );
59 59
             $this->filterBlockClass();
60
-            if (!$this->hasVisibleFields($shortcode, $attributes)) {
60
+            if( !$this->hasVisibleFields( $shortcode, $attributes ) ) {
61 61
                 $this->filterInterpolation();
62 62
             }
63 63
         }
64
-        return $shortcode->buildBlock($attributes);
64
+        return $shortcode->buildBlock( $attributes );
65 65
     }
66 66
 
67 67
     /**
@@ -69,9 +69,9 @@  discard block
 block discarded – undo
69 69
      */
70 70
     protected function filterInterpolation()
71 71
     {
72
-        add_filter('site-reviews/interpolate/reviews-summary', function ($context) {
72
+        add_filter( 'site-reviews/interpolate/reviews-summary', function( $context ) {
73 73
             $context['class'] = 'glsr-default glsr-block-disabled';
74
-            $context['text'] = __('You have hidden all of the fields for this block.', 'site-reviews');
74
+            $context['text'] = __( 'You have hidden all of the fields for this block.', 'site-reviews' );
75 75
             return $context;
76 76
         });
77 77
     }
Please login to merge, or discard this patch.
plugin/Blocks/BlockGenerator.php 3 patches
Indentation   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -7,72 +7,72 @@
 block discarded – undo
7 7
 
8 8
 abstract class BlockGenerator
9 9
 {
10
-    /**
11
-     * @return array
12
-     */
13
-    public function attributes()
14
-    {
15
-        return [];
16
-    }
10
+	/**
11
+	 * @return array
12
+	 */
13
+	public function attributes()
14
+	{
15
+		return [];
16
+	}
17 17
 
18
-    /**
19
-     * @return array
20
-     */
21
-    public function normalize(array $attributes)
22
-    {
23
-        $hide = array_flip(explode(',', $attributes['hide']));
24
-        unset($hide['if_empty']);
25
-        $attributes['hide'] = implode(',', array_keys($hide));
26
-        if ('post_id' === Arr::get($attributes, 'assigned_to')) {
27
-            $attributes['assigned_to'] = $attributes['post_id'];
28
-        } elseif ('parent_id' === Arr::get($attributes, 'assigned_to')) {
29
-            $attributes['assigned_to'] = wp_get_post_parent_id($attributes['post_id']);
30
-        }
31
-        return $attributes;
32
-    }
18
+	/**
19
+	 * @return array
20
+	 */
21
+	public function normalize(array $attributes)
22
+	{
23
+		$hide = array_flip(explode(',', $attributes['hide']));
24
+		unset($hide['if_empty']);
25
+		$attributes['hide'] = implode(',', array_keys($hide));
26
+		if ('post_id' === Arr::get($attributes, 'assigned_to')) {
27
+			$attributes['assigned_to'] = $attributes['post_id'];
28
+		} elseif ('parent_id' === Arr::get($attributes, 'assigned_to')) {
29
+			$attributes['assigned_to'] = wp_get_post_parent_id($attributes['post_id']);
30
+		}
31
+		return $attributes;
32
+	}
33 33
 
34
-    /**
35
-     * @return void
36
-     */
37
-    public function register($block)
38
-    {
39
-        if (!function_exists('register_block_type')) {
40
-            return;
41
-        }
42
-        register_block_type(Application::ID.'/'.$block, [
43
-            'attributes' => $this->attributes(),
44
-            'editor_script' => Application::ID.'/blocks',
45
-            'editor_style' => Application::ID.'/blocks',
46
-            'render_callback' => [$this, 'render'],
47
-            'style' => Application::ID,
48
-        ]);
49
-    }
34
+	/**
35
+	 * @return void
36
+	 */
37
+	public function register($block)
38
+	{
39
+		if (!function_exists('register_block_type')) {
40
+			return;
41
+		}
42
+		register_block_type(Application::ID.'/'.$block, [
43
+			'attributes' => $this->attributes(),
44
+			'editor_script' => Application::ID.'/blocks',
45
+			'editor_style' => Application::ID.'/blocks',
46
+			'render_callback' => [$this, 'render'],
47
+			'style' => Application::ID,
48
+		]);
49
+	}
50 50
 
51
-    /**
52
-     * @return void
53
-     */
54
-    abstract public function render(array $attributes);
51
+	/**
52
+	 * @return void
53
+	 */
54
+	abstract public function render(array $attributes);
55 55
 
56
-    /**
57
-     * @return void
58
-     */
59
-    protected function filterBlockClass()
60
-    {
61
-        add_filter('site-reviews/style', function () {
62
-            return 'default';
63
-        });
64
-    }
56
+	/**
57
+	 * @return void
58
+	 */
59
+	protected function filterBlockClass()
60
+	{
61
+		add_filter('site-reviews/style', function () {
62
+			return 'default';
63
+		});
64
+	}
65 65
 
66
-    /**
67
-     * @param mixed $shortcode
68
-     * @return bool
69
-     */
70
-    protected function hasVisibleFields($shortcode, array $attributes)
71
-    {
72
-        $args = $shortcode->normalizeAtts($attributes);
73
-        $defaults = $shortcode->getHideOptions();
74
-        $hide = array_flip($args['hide']);
75
-        unset($defaults['if_empty'], $hide['if_empty']);
76
-        return !empty(array_diff_key($defaults, $hide));
77
-    }
66
+	/**
67
+	 * @param mixed $shortcode
68
+	 * @return bool
69
+	 */
70
+	protected function hasVisibleFields($shortcode, array $attributes)
71
+	{
72
+		$args = $shortcode->normalizeAtts($attributes);
73
+		$defaults = $shortcode->getHideOptions();
74
+		$hide = array_flip($args['hide']);
75
+		unset($defaults['if_empty'], $hide['if_empty']);
76
+		return !empty(array_diff_key($defaults, $hide));
77
+	}
78 78
 }
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -18,15 +18,15 @@  discard block
 block discarded – undo
18 18
     /**
19 19
      * @return array
20 20
      */
21
-    public function normalize(array $attributes)
21
+    public function normalize( array $attributes )
22 22
     {
23
-        $hide = array_flip(explode(',', $attributes['hide']));
23
+        $hide = array_flip( explode( ',', $attributes['hide'] ) );
24 24
         unset($hide['if_empty']);
25
-        $attributes['hide'] = implode(',', array_keys($hide));
26
-        if ('post_id' === Arr::get($attributes, 'assigned_to')) {
25
+        $attributes['hide'] = implode( ',', array_keys( $hide ) );
26
+        if( 'post_id' === Arr::get( $attributes, 'assigned_to' ) ) {
27 27
             $attributes['assigned_to'] = $attributes['post_id'];
28
-        } elseif ('parent_id' === Arr::get($attributes, 'assigned_to')) {
29
-            $attributes['assigned_to'] = wp_get_post_parent_id($attributes['post_id']);
28
+        } elseif( 'parent_id' === Arr::get( $attributes, 'assigned_to' ) ) {
29
+            $attributes['assigned_to'] = wp_get_post_parent_id( $attributes['post_id'] );
30 30
         }
31 31
         return $attributes;
32 32
     }
@@ -34,31 +34,31 @@  discard block
 block discarded – undo
34 34
     /**
35 35
      * @return void
36 36
      */
37
-    public function register($block)
37
+    public function register( $block )
38 38
     {
39
-        if (!function_exists('register_block_type')) {
39
+        if( !function_exists( 'register_block_type' ) ) {
40 40
             return;
41 41
         }
42
-        register_block_type(Application::ID.'/'.$block, [
42
+        register_block_type( Application::ID.'/'.$block, [
43 43
             'attributes' => $this->attributes(),
44 44
             'editor_script' => Application::ID.'/blocks',
45 45
             'editor_style' => Application::ID.'/blocks',
46 46
             'render_callback' => [$this, 'render'],
47 47
             'style' => Application::ID,
48
-        ]);
48
+        ] );
49 49
     }
50 50
 
51 51
     /**
52 52
      * @return void
53 53
      */
54
-    abstract public function render(array $attributes);
54
+    abstract public function render( array $attributes );
55 55
 
56 56
     /**
57 57
      * @return void
58 58
      */
59 59
     protected function filterBlockClass()
60 60
     {
61
-        add_filter('site-reviews/style', function () {
61
+        add_filter( 'site-reviews/style', function() {
62 62
             return 'default';
63 63
         });
64 64
     }
@@ -67,12 +67,12 @@  discard block
 block discarded – undo
67 67
      * @param mixed $shortcode
68 68
      * @return bool
69 69
      */
70
-    protected function hasVisibleFields($shortcode, array $attributes)
70
+    protected function hasVisibleFields( $shortcode, array $attributes )
71 71
     {
72
-        $args = $shortcode->normalizeAtts($attributes);
72
+        $args = $shortcode->normalizeAtts( $attributes );
73 73
         $defaults = $shortcode->getHideOptions();
74
-        $hide = array_flip($args['hide']);
74
+        $hide = array_flip( $args['hide'] );
75 75
         unset($defaults['if_empty'], $hide['if_empty']);
76
-        return !empty(array_diff_key($defaults, $hide));
76
+        return !empty(array_diff_key( $defaults, $hide ));
77 77
     }
78 78
 }
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -25,7 +25,8 @@
 block discarded – undo
25 25
         $attributes['hide'] = implode(',', array_keys($hide));
26 26
         if ('post_id' === Arr::get($attributes, 'assigned_to')) {
27 27
             $attributes['assigned_to'] = $attributes['post_id'];
28
-        } elseif ('parent_id' === Arr::get($attributes, 'assigned_to')) {
28
+        }
29
+        elseif ('parent_id' === Arr::get($attributes, 'assigned_to')) {
29 30
             $attributes['assigned_to'] = wp_get_post_parent_id($attributes['post_id']);
30 31
         }
31 32
         return $attributes;
Please login to merge, or discard this patch.
plugin/Helpers/Str.php 2 patches
Indentation   +228 added lines, -228 removed lines patch added patch discarded remove patch
@@ -4,232 +4,232 @@
 block discarded – undo
4 4
 
5 5
 class Str
6 6
 {
7
-    /**
8
-     * @param string $subject
9
-     * @param string $search
10
-     * @return string
11
-     */
12
-    public static function afterLast($subject, $search)
13
-    {
14
-        return '' === $search
15
-            ? $subject
16
-            : array_reverse(explode($search, $subject))[0];
17
-    }
18
-
19
-    /**
20
-     * @param string $subject
21
-     * @param string $search
22
-     * @return string
23
-     */
24
-    public static function before($subject, $search)
25
-    {
26
-        return $search === '' ? $subject : explode($search, $subject)[0];
27
-    }
28
-
29
-    /**
30
-     * @param string $string
31
-     * @return string
32
-     */
33
-    public static function camelCase($string)
34
-    {
35
-        $string = ucwords(str_replace(['-', '_'], ' ', trim($string)));
36
-        return str_replace(' ', '', $string);
37
-    }
38
-
39
-    /**
40
-     * @param string $haystack
41
-     * @param string $needle
42
-     * @return bool
43
-     */
44
-    public static function contains($haystack, $needle)
45
-    {
46
-        return false !== strpos($haystack, $needle);
47
-    }
48
-
49
-    /**
50
-     * @param string $name
51
-     * @param string $nameType first|first_initial|initials|last|last_initial
52
-     * @param string $initialType period|period_space|space
53
-     * @return string
54
-     */
55
-    public static function convertName($name, $nameType = '', $initialType = '')
56
-    {
57
-        $names = preg_split('/\W/', $name, 0, PREG_SPLIT_NO_EMPTY);
58
-        $firstName = array_shift($names);
59
-        $lastName = array_pop($names);
60
-        $initialTypes = [
61
-            'period' => '.',
62
-            'period_space' => '. ',
63
-            'space' => ' ',
64
-        ];
65
-        $initialPunctuation = (string) Arr::get($initialTypes, $initialType, ' ');
66
-        if ('initials' == $nameType) {
67
-            return static::convertToInitials($name, $initialPunctuation);
68
-        }
69
-        $nameTypes = [
70
-            'first' => $firstName,
71
-            'first_initial' => substr($firstName, 0, 1).$initialPunctuation.$lastName,
72
-            'last' => $lastName,
73
-            'last_initial' => $firstName.' '.substr($lastName, 0, 1).$initialPunctuation,
74
-        ];
75
-        return trim((string) Arr::get($nameTypes, $nameType, $name));
76
-    }
77
-
78
-    /**
79
-     * @param string $path
80
-     * @param string $prefix
81
-     * @return string
82
-     */
83
-    public static function convertPathToId($path, $prefix = '')
84
-    {
85
-        return str_replace(['[', ']'], ['-', ''], static::convertPathToName($path, $prefix));
86
-    }
87
-
88
-    /**
89
-     * @param string $path
90
-     * @param string $prefix
91
-     * @return string
92
-     */
93
-    public static function convertPathToName($path, $prefix = '')
94
-    {
95
-        $levels = explode('.', $path);
96
-        return array_reduce($levels, function ($result, $value) {
97
-            return $result .= '['.$value.']';
98
-        }, $prefix);
99
-    }
100
-
101
-    /**
102
-     * @param string $name
103
-     * @param string $initialPunctuation
104
-     * @return string
105
-     */
106
-    public static function convertToInitials($name, $initialPunctuation = '')
107
-    {
108
-        preg_match_all('/(?<=\s|\b)\pL/u', $name, $matches);
109
-        return array_reduce($matches[0], function ($carry, $word) use ($initialPunctuation) {
110
-            return $carry.strtoupper(substr($word, 0, 1)).$initialPunctuation;
111
-        });
112
-    }
113
-
114
-    /**
115
-     * @param string $string
116
-     * @return string
117
-     */
118
-    public static function dashCase($string)
119
-    {
120
-        return str_replace('_', '-', static::snakeCase($string));
121
-    }
122
-
123
-    /**
124
-     * @param string $needle
125
-     * @param string $haystack
126
-     * @return bool
127
-     */
128
-    public static function endsWith($needle, $haystack)
129
-    {
130
-        $length = strlen($needle);
131
-        return 0 != $length
132
-            ? substr($haystack, -$length) === $needle
133
-            : true;
134
-    }
135
-
136
-    /**
137
-     * @param string $prefix
138
-     * @param string $string
139
-     * @param string|null $trim
140
-     * @return string
141
-     */
142
-    public static function prefix($prefix, $string, $trim = null)
143
-    {
144
-        if (empty($string)) {
145
-            return $string;
146
-        }
147
-        if (null === $trim) {
148
-            $trim = $prefix;
149
-        }
150
-        return $prefix.trim(static::removePrefix($trim, $string));
151
-    }
152
-
153
-    /**
154
-     * @param string $prefix
155
-     * @param string $string
156
-     * @return string
157
-     */
158
-    public static function removePrefix($prefix, $string)
159
-    {
160
-        return static::startsWith($prefix, $string)
161
-            ? substr($string, strlen($prefix))
162
-            : $string;
163
-    }
164
-
165
-    /**
166
-     * @param string $search
167
-     * @param string $replace
168
-     * @param string $subject
169
-     * @return string
170
-     */
171
-    public static function replaceFirst($search, $replace, $subject)
172
-    {
173
-        if ($search == '') {
174
-            return $subject;
175
-        }
176
-        $position = strpos($subject, $search);
177
-        if ($position !== false) {
178
-            return substr_replace($subject, $replace, $position, strlen($search));
179
-        }
180
-        return $subject;
181
-    }
182
-
183
-    /**
184
-     * @param string $search
185
-     * @param string $replace
186
-     * @param string $subject
187
-     * @return string
188
-     */
189
-    public static function replaceLast($search, $replace, $subject)
190
-    {
191
-        $position = strrpos($subject, $search);
192
-        if ($position !== false) {
193
-            return substr_replace($subject, $replace, $position, strlen($search));
194
-        }
195
-        return $subject;
196
-    }
197
-
198
-    /**
199
-     * @param string $string
200
-     * @return string
201
-     */
202
-    public static function snakeCase($string)
203
-    {
204
-        if (!ctype_lower($string)) {
205
-            $string = preg_replace('/\s+/u', '', $string);
206
-            $string = preg_replace('/(.)(?=[A-Z])/u', '$1_', $string);
207
-            $string = function_exists('mb_strtolower')
208
-                ? mb_strtolower($string, 'UTF-8')
209
-                : strtolower($string);
210
-        }
211
-        return str_replace('-', '_', $string);
212
-    }
213
-
214
-    /**
215
-     * @param string $needle
216
-     * @param string $haystack
217
-     * @return bool
218
-     */
219
-    public static function startsWith($needle, $haystack)
220
-    {
221
-        return substr($haystack, 0, strlen($needle)) === $needle;
222
-    }
223
-
224
-    /**
225
-     * @param string $string
226
-     * @param int $length
227
-     * @return string
228
-     */
229
-    public static function truncate($string, $length)
230
-    {
231
-        return strlen($string) > $length
232
-            ? substr($string, 0, $length)
233
-            : $string;
234
-    }
7
+	/**
8
+	 * @param string $subject
9
+	 * @param string $search
10
+	 * @return string
11
+	 */
12
+	public static function afterLast($subject, $search)
13
+	{
14
+		return '' === $search
15
+			? $subject
16
+			: array_reverse(explode($search, $subject))[0];
17
+	}
18
+
19
+	/**
20
+	 * @param string $subject
21
+	 * @param string $search
22
+	 * @return string
23
+	 */
24
+	public static function before($subject, $search)
25
+	{
26
+		return $search === '' ? $subject : explode($search, $subject)[0];
27
+	}
28
+
29
+	/**
30
+	 * @param string $string
31
+	 * @return string
32
+	 */
33
+	public static function camelCase($string)
34
+	{
35
+		$string = ucwords(str_replace(['-', '_'], ' ', trim($string)));
36
+		return str_replace(' ', '', $string);
37
+	}
38
+
39
+	/**
40
+	 * @param string $haystack
41
+	 * @param string $needle
42
+	 * @return bool
43
+	 */
44
+	public static function contains($haystack, $needle)
45
+	{
46
+		return false !== strpos($haystack, $needle);
47
+	}
48
+
49
+	/**
50
+	 * @param string $name
51
+	 * @param string $nameType first|first_initial|initials|last|last_initial
52
+	 * @param string $initialType period|period_space|space
53
+	 * @return string
54
+	 */
55
+	public static function convertName($name, $nameType = '', $initialType = '')
56
+	{
57
+		$names = preg_split('/\W/', $name, 0, PREG_SPLIT_NO_EMPTY);
58
+		$firstName = array_shift($names);
59
+		$lastName = array_pop($names);
60
+		$initialTypes = [
61
+			'period' => '.',
62
+			'period_space' => '. ',
63
+			'space' => ' ',
64
+		];
65
+		$initialPunctuation = (string) Arr::get($initialTypes, $initialType, ' ');
66
+		if ('initials' == $nameType) {
67
+			return static::convertToInitials($name, $initialPunctuation);
68
+		}
69
+		$nameTypes = [
70
+			'first' => $firstName,
71
+			'first_initial' => substr($firstName, 0, 1).$initialPunctuation.$lastName,
72
+			'last' => $lastName,
73
+			'last_initial' => $firstName.' '.substr($lastName, 0, 1).$initialPunctuation,
74
+		];
75
+		return trim((string) Arr::get($nameTypes, $nameType, $name));
76
+	}
77
+
78
+	/**
79
+	 * @param string $path
80
+	 * @param string $prefix
81
+	 * @return string
82
+	 */
83
+	public static function convertPathToId($path, $prefix = '')
84
+	{
85
+		return str_replace(['[', ']'], ['-', ''], static::convertPathToName($path, $prefix));
86
+	}
87
+
88
+	/**
89
+	 * @param string $path
90
+	 * @param string $prefix
91
+	 * @return string
92
+	 */
93
+	public static function convertPathToName($path, $prefix = '')
94
+	{
95
+		$levels = explode('.', $path);
96
+		return array_reduce($levels, function ($result, $value) {
97
+			return $result .= '['.$value.']';
98
+		}, $prefix);
99
+	}
100
+
101
+	/**
102
+	 * @param string $name
103
+	 * @param string $initialPunctuation
104
+	 * @return string
105
+	 */
106
+	public static function convertToInitials($name, $initialPunctuation = '')
107
+	{
108
+		preg_match_all('/(?<=\s|\b)\pL/u', $name, $matches);
109
+		return array_reduce($matches[0], function ($carry, $word) use ($initialPunctuation) {
110
+			return $carry.strtoupper(substr($word, 0, 1)).$initialPunctuation;
111
+		});
112
+	}
113
+
114
+	/**
115
+	 * @param string $string
116
+	 * @return string
117
+	 */
118
+	public static function dashCase($string)
119
+	{
120
+		return str_replace('_', '-', static::snakeCase($string));
121
+	}
122
+
123
+	/**
124
+	 * @param string $needle
125
+	 * @param string $haystack
126
+	 * @return bool
127
+	 */
128
+	public static function endsWith($needle, $haystack)
129
+	{
130
+		$length = strlen($needle);
131
+		return 0 != $length
132
+			? substr($haystack, -$length) === $needle
133
+			: true;
134
+	}
135
+
136
+	/**
137
+	 * @param string $prefix
138
+	 * @param string $string
139
+	 * @param string|null $trim
140
+	 * @return string
141
+	 */
142
+	public static function prefix($prefix, $string, $trim = null)
143
+	{
144
+		if (empty($string)) {
145
+			return $string;
146
+		}
147
+		if (null === $trim) {
148
+			$trim = $prefix;
149
+		}
150
+		return $prefix.trim(static::removePrefix($trim, $string));
151
+	}
152
+
153
+	/**
154
+	 * @param string $prefix
155
+	 * @param string $string
156
+	 * @return string
157
+	 */
158
+	public static function removePrefix($prefix, $string)
159
+	{
160
+		return static::startsWith($prefix, $string)
161
+			? substr($string, strlen($prefix))
162
+			: $string;
163
+	}
164
+
165
+	/**
166
+	 * @param string $search
167
+	 * @param string $replace
168
+	 * @param string $subject
169
+	 * @return string
170
+	 */
171
+	public static function replaceFirst($search, $replace, $subject)
172
+	{
173
+		if ($search == '') {
174
+			return $subject;
175
+		}
176
+		$position = strpos($subject, $search);
177
+		if ($position !== false) {
178
+			return substr_replace($subject, $replace, $position, strlen($search));
179
+		}
180
+		return $subject;
181
+	}
182
+
183
+	/**
184
+	 * @param string $search
185
+	 * @param string $replace
186
+	 * @param string $subject
187
+	 * @return string
188
+	 */
189
+	public static function replaceLast($search, $replace, $subject)
190
+	{
191
+		$position = strrpos($subject, $search);
192
+		if ($position !== false) {
193
+			return substr_replace($subject, $replace, $position, strlen($search));
194
+		}
195
+		return $subject;
196
+	}
197
+
198
+	/**
199
+	 * @param string $string
200
+	 * @return string
201
+	 */
202
+	public static function snakeCase($string)
203
+	{
204
+		if (!ctype_lower($string)) {
205
+			$string = preg_replace('/\s+/u', '', $string);
206
+			$string = preg_replace('/(.)(?=[A-Z])/u', '$1_', $string);
207
+			$string = function_exists('mb_strtolower')
208
+				? mb_strtolower($string, 'UTF-8')
209
+				: strtolower($string);
210
+		}
211
+		return str_replace('-', '_', $string);
212
+	}
213
+
214
+	/**
215
+	 * @param string $needle
216
+	 * @param string $haystack
217
+	 * @return bool
218
+	 */
219
+	public static function startsWith($needle, $haystack)
220
+	{
221
+		return substr($haystack, 0, strlen($needle)) === $needle;
222
+	}
223
+
224
+	/**
225
+	 * @param string $string
226
+	 * @param int $length
227
+	 * @return string
228
+	 */
229
+	public static function truncate($string, $length)
230
+	{
231
+		return strlen($string) > $length
232
+			? substr($string, 0, $length)
233
+			: $string;
234
+	}
235 235
 }
Please login to merge, or discard this patch.
Spacing   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -9,11 +9,11 @@  discard block
 block discarded – undo
9 9
      * @param string $search
10 10
      * @return string
11 11
      */
12
-    public static function afterLast($subject, $search)
12
+    public static function afterLast( $subject, $search )
13 13
     {
14 14
         return '' === $search
15 15
             ? $subject
16
-            : array_reverse(explode($search, $subject))[0];
16
+            : array_reverse( explode( $search, $subject ) )[0];
17 17
     }
18 18
 
19 19
     /**
@@ -21,19 +21,19 @@  discard block
 block discarded – undo
21 21
      * @param string $search
22 22
      * @return string
23 23
      */
24
-    public static function before($subject, $search)
24
+    public static function before( $subject, $search )
25 25
     {
26
-        return $search === '' ? $subject : explode($search, $subject)[0];
26
+        return $search === '' ? $subject : explode( $search, $subject )[0];
27 27
     }
28 28
 
29 29
     /**
30 30
      * @param string $string
31 31
      * @return string
32 32
      */
33
-    public static function camelCase($string)
33
+    public static function camelCase( $string )
34 34
     {
35
-        $string = ucwords(str_replace(['-', '_'], ' ', trim($string)));
36
-        return str_replace(' ', '', $string);
35
+        $string = ucwords( str_replace( ['-', '_'], ' ', trim( $string ) ) );
36
+        return str_replace( ' ', '', $string );
37 37
     }
38 38
 
39 39
     /**
@@ -41,9 +41,9 @@  discard block
 block discarded – undo
41 41
      * @param string $needle
42 42
      * @return bool
43 43
      */
44
-    public static function contains($haystack, $needle)
44
+    public static function contains( $haystack, $needle )
45 45
     {
46
-        return false !== strpos($haystack, $needle);
46
+        return false !== strpos( $haystack, $needle );
47 47
     }
48 48
 
49 49
     /**
@@ -52,27 +52,27 @@  discard block
 block discarded – undo
52 52
      * @param string $initialType period|period_space|space
53 53
      * @return string
54 54
      */
55
-    public static function convertName($name, $nameType = '', $initialType = '')
55
+    public static function convertName( $name, $nameType = '', $initialType = '' )
56 56
     {
57
-        $names = preg_split('/\W/', $name, 0, PREG_SPLIT_NO_EMPTY);
58
-        $firstName = array_shift($names);
59
-        $lastName = array_pop($names);
57
+        $names = preg_split( '/\W/', $name, 0, PREG_SPLIT_NO_EMPTY );
58
+        $firstName = array_shift( $names );
59
+        $lastName = array_pop( $names );
60 60
         $initialTypes = [
61 61
             'period' => '.',
62 62
             'period_space' => '. ',
63 63
             'space' => ' ',
64 64
         ];
65
-        $initialPunctuation = (string) Arr::get($initialTypes, $initialType, ' ');
66
-        if ('initials' == $nameType) {
67
-            return static::convertToInitials($name, $initialPunctuation);
65
+        $initialPunctuation = (string)Arr::get( $initialTypes, $initialType, ' ' );
66
+        if( 'initials' == $nameType ) {
67
+            return static::convertToInitials( $name, $initialPunctuation );
68 68
         }
69 69
         $nameTypes = [
70 70
             'first' => $firstName,
71
-            'first_initial' => substr($firstName, 0, 1).$initialPunctuation.$lastName,
71
+            'first_initial' => substr( $firstName, 0, 1 ).$initialPunctuation.$lastName,
72 72
             'last' => $lastName,
73
-            'last_initial' => $firstName.' '.substr($lastName, 0, 1).$initialPunctuation,
73
+            'last_initial' => $firstName.' '.substr( $lastName, 0, 1 ).$initialPunctuation,
74 74
         ];
75
-        return trim((string) Arr::get($nameTypes, $nameType, $name));
75
+        return trim( (string)Arr::get( $nameTypes, $nameType, $name ) );
76 76
     }
77 77
 
78 78
     /**
@@ -80,9 +80,9 @@  discard block
 block discarded – undo
80 80
      * @param string $prefix
81 81
      * @return string
82 82
      */
83
-    public static function convertPathToId($path, $prefix = '')
83
+    public static function convertPathToId( $path, $prefix = '' )
84 84
     {
85
-        return str_replace(['[', ']'], ['-', ''], static::convertPathToName($path, $prefix));
85
+        return str_replace( ['[', ']'], ['-', ''], static::convertPathToName( $path, $prefix ) );
86 86
     }
87 87
 
88 88
     /**
@@ -90,12 +90,12 @@  discard block
 block discarded – undo
90 90
      * @param string $prefix
91 91
      * @return string
92 92
      */
93
-    public static function convertPathToName($path, $prefix = '')
93
+    public static function convertPathToName( $path, $prefix = '' )
94 94
     {
95
-        $levels = explode('.', $path);
96
-        return array_reduce($levels, function ($result, $value) {
95
+        $levels = explode( '.', $path );
96
+        return array_reduce( $levels, function( $result, $value ) {
97 97
             return $result .= '['.$value.']';
98
-        }, $prefix);
98
+        }, $prefix );
99 99
     }
100 100
 
101 101
     /**
@@ -103,11 +103,11 @@  discard block
 block discarded – undo
103 103
      * @param string $initialPunctuation
104 104
      * @return string
105 105
      */
106
-    public static function convertToInitials($name, $initialPunctuation = '')
106
+    public static function convertToInitials( $name, $initialPunctuation = '' )
107 107
     {
108
-        preg_match_all('/(?<=\s|\b)\pL/u', $name, $matches);
109
-        return array_reduce($matches[0], function ($carry, $word) use ($initialPunctuation) {
110
-            return $carry.strtoupper(substr($word, 0, 1)).$initialPunctuation;
108
+        preg_match_all( '/(?<=\s|\b)\pL/u', $name, $matches );
109
+        return array_reduce( $matches[0], function( $carry, $word ) use ($initialPunctuation) {
110
+            return $carry.strtoupper( substr( $word, 0, 1 ) ).$initialPunctuation;
111 111
         });
112 112
     }
113 113
 
@@ -115,9 +115,9 @@  discard block
 block discarded – undo
115 115
      * @param string $string
116 116
      * @return string
117 117
      */
118
-    public static function dashCase($string)
118
+    public static function dashCase( $string )
119 119
     {
120
-        return str_replace('_', '-', static::snakeCase($string));
120
+        return str_replace( '_', '-', static::snakeCase( $string ) );
121 121
     }
122 122
 
123 123
     /**
@@ -125,11 +125,11 @@  discard block
 block discarded – undo
125 125
      * @param string $haystack
126 126
      * @return bool
127 127
      */
128
-    public static function endsWith($needle, $haystack)
128
+    public static function endsWith( $needle, $haystack )
129 129
     {
130
-        $length = strlen($needle);
130
+        $length = strlen( $needle );
131 131
         return 0 != $length
132
-            ? substr($haystack, -$length) === $needle
132
+            ? substr( $haystack, -$length ) === $needle
133 133
             : true;
134 134
     }
135 135
 
@@ -139,15 +139,15 @@  discard block
 block discarded – undo
139 139
      * @param string|null $trim
140 140
      * @return string
141 141
      */
142
-    public static function prefix($prefix, $string, $trim = null)
142
+    public static function prefix( $prefix, $string, $trim = null )
143 143
     {
144
-        if (empty($string)) {
144
+        if( empty($string) ) {
145 145
             return $string;
146 146
         }
147
-        if (null === $trim) {
147
+        if( null === $trim ) {
148 148
             $trim = $prefix;
149 149
         }
150
-        return $prefix.trim(static::removePrefix($trim, $string));
150
+        return $prefix.trim( static::removePrefix( $trim, $string ) );
151 151
     }
152 152
 
153 153
     /**
@@ -155,10 +155,10 @@  discard block
 block discarded – undo
155 155
      * @param string $string
156 156
      * @return string
157 157
      */
158
-    public static function removePrefix($prefix, $string)
158
+    public static function removePrefix( $prefix, $string )
159 159
     {
160
-        return static::startsWith($prefix, $string)
161
-            ? substr($string, strlen($prefix))
160
+        return static::startsWith( $prefix, $string )
161
+            ? substr( $string, strlen( $prefix ) )
162 162
             : $string;
163 163
     }
164 164
 
@@ -168,14 +168,14 @@  discard block
 block discarded – undo
168 168
      * @param string $subject
169 169
      * @return string
170 170
      */
171
-    public static function replaceFirst($search, $replace, $subject)
171
+    public static function replaceFirst( $search, $replace, $subject )
172 172
     {
173
-        if ($search == '') {
173
+        if( $search == '' ) {
174 174
             return $subject;
175 175
         }
176
-        $position = strpos($subject, $search);
177
-        if ($position !== false) {
178
-            return substr_replace($subject, $replace, $position, strlen($search));
176
+        $position = strpos( $subject, $search );
177
+        if( $position !== false ) {
178
+            return substr_replace( $subject, $replace, $position, strlen( $search ) );
179 179
         }
180 180
         return $subject;
181 181
     }
@@ -186,11 +186,11 @@  discard block
 block discarded – undo
186 186
      * @param string $subject
187 187
      * @return string
188 188
      */
189
-    public static function replaceLast($search, $replace, $subject)
189
+    public static function replaceLast( $search, $replace, $subject )
190 190
     {
191
-        $position = strrpos($subject, $search);
192
-        if ($position !== false) {
193
-            return substr_replace($subject, $replace, $position, strlen($search));
191
+        $position = strrpos( $subject, $search );
192
+        if( $position !== false ) {
193
+            return substr_replace( $subject, $replace, $position, strlen( $search ) );
194 194
         }
195 195
         return $subject;
196 196
     }
@@ -199,16 +199,16 @@  discard block
 block discarded – undo
199 199
      * @param string $string
200 200
      * @return string
201 201
      */
202
-    public static function snakeCase($string)
202
+    public static function snakeCase( $string )
203 203
     {
204
-        if (!ctype_lower($string)) {
205
-            $string = preg_replace('/\s+/u', '', $string);
206
-            $string = preg_replace('/(.)(?=[A-Z])/u', '$1_', $string);
207
-            $string = function_exists('mb_strtolower')
208
-                ? mb_strtolower($string, 'UTF-8')
209
-                : strtolower($string);
204
+        if( !ctype_lower( $string ) ) {
205
+            $string = preg_replace( '/\s+/u', '', $string );
206
+            $string = preg_replace( '/(.)(?=[A-Z])/u', '$1_', $string );
207
+            $string = function_exists( 'mb_strtolower' )
208
+                ? mb_strtolower( $string, 'UTF-8' )
209
+                : strtolower( $string );
210 210
         }
211
-        return str_replace('-', '_', $string);
211
+        return str_replace( '-', '_', $string );
212 212
     }
213 213
 
214 214
     /**
@@ -216,9 +216,9 @@  discard block
 block discarded – undo
216 216
      * @param string $haystack
217 217
      * @return bool
218 218
      */
219
-    public static function startsWith($needle, $haystack)
219
+    public static function startsWith( $needle, $haystack )
220 220
     {
221
-        return substr($haystack, 0, strlen($needle)) === $needle;
221
+        return substr( $haystack, 0, strlen( $needle ) ) === $needle;
222 222
     }
223 223
 
224 224
     /**
@@ -226,10 +226,10 @@  discard block
 block discarded – undo
226 226
      * @param int $length
227 227
      * @return string
228 228
      */
229
-    public static function truncate($string, $length)
229
+    public static function truncate( $string, $length )
230 230
     {
231
-        return strlen($string) > $length
232
-            ? substr($string, 0, $length)
231
+        return strlen( $string ) > $length
232
+            ? substr( $string, 0, $length )
233 233
             : $string;
234 234
     }
235 235
 }
Please login to merge, or discard this patch.
plugin/Helpers/Arr.php 3 patches
Indentation   +211 added lines, -211 removed lines patch added patch discarded remove patch
@@ -4,215 +4,215 @@
 block discarded – undo
4 4
 
5 5
 class Arr
6 6
 {
7
-    /**
8
-     * @return bool
9
-     */
10
-    public static function compare(array $arr1, array $arr2)
11
-    {
12
-        sort($arr1);
13
-        sort($arr2);
14
-        return $arr1 == $arr2;
15
-    }
16
-
17
-    /**
18
-     * @param mixed $array
19
-     * @return array
20
-     */
21
-    public static function consolidate($array)
22
-    {
23
-        return is_array($array) || is_object($array)
24
-            ? (array) $array
25
-            : [];
26
-    }
27
-
28
-    /**
29
-     * @return array
30
-     */
31
-    public static function convertFromDotNotation(array $array)
32
-    {
33
-        $results = [];
34
-        foreach ($array as $path => $value) {
35
-            $results = static::set($results, $path, $value);
36
-        }
37
-        return $results;
38
-    }
39
-
40
-    /**
41
-     * @param string $string
42
-     * @param mixed $callback
43
-     * @return array
44
-     */
45
-    public static function convertFromString($string, $callback = null)
46
-    {
47
-        $array = array_map('trim', explode(',', $string));
48
-        return $callback
49
-            ? array_filter($array, $callback)
50
-            : array_filter($array);
51
-    }
52
-
53
-    /**
54
-     * @param bool $flattenValue
55
-     * @param string $prefix
56
-     * @return array
57
-     */
58
-    public static function flatten(array $array, $flattenValue = false, $prefix = '')
59
-    {
60
-        $result = [];
61
-        foreach ($array as $key => $value) {
62
-            $newKey = ltrim($prefix.'.'.$key, '.');
63
-            if (static::isIndexedAndFlat($value)) {
64
-                if ($flattenValue) {
65
-                    $value = '['.implode(', ', $value).']';
66
-                }
67
-            } elseif (is_array($value)) {
68
-                $result = array_merge($result, static::flatten($value, $flattenValue, $newKey));
69
-                continue;
70
-            }
71
-            $result[$newKey] = $value;
72
-        }
73
-        return $result;
74
-    }
75
-
76
-    /**
77
-     * Get a value from an array of values using a dot-notation path as reference.
78
-     * @param mixed $data
79
-     * @param string $path
80
-     * @param mixed $fallback
81
-     * @return mixed
82
-     */
83
-    public static function get($data, $path = '', $fallback = '')
84
-    {
85
-        $data = static::consolidate($data);
86
-        $keys = explode('.', $path);
87
-        foreach ($keys as $key) {
88
-            if (!isset($data[$key])) {
89
-                return $fallback;
90
-            }
91
-            $data = $data[$key];
92
-        }
93
-        return $data;
94
-    }
95
-
96
-    /**
97
-     * @param string $key
98
-     * @return array
99
-     */
100
-    public static function insertAfter($key, array $array, array $insert)
101
-    {
102
-        return static::insert($array, $insert, $key, 'after');
103
-    }
104
-
105
-    /**
106
-     * @param string $key
107
-     * @return array
108
-     */
109
-    public static function insertBefore($key, array $array, array $insert)
110
-    {
111
-        return static::insert($array, $insert, $key, 'before');
112
-    }
113
-
114
-    /**
115
-     * @param string $key
116
-     * @param string $position
117
-     * @return array
118
-     */
119
-    public static function insert(array $array, array $insert, $key, $position = 'before')
120
-    {
121
-        $keyPosition = intval(array_search($key, array_keys($array)));
122
-        if ('after' == $position) {
123
-            ++$keyPosition;
124
-        }
125
-        if (false !== $keyPosition) {
126
-            $result = array_slice($array, 0, $keyPosition);
127
-            $result = array_merge($result, $insert);
128
-            return array_merge($result, array_slice($array, $keyPosition));
129
-        }
130
-        return array_merge($array, $insert);
131
-    }
132
-
133
-    /**
134
-     * @param mixed $array
135
-     * @return bool
136
-     */
137
-    public static function isIndexedAndFlat($array)
138
-    {
139
-        if (!is_array($array) || array_filter($array, 'is_array')) {
140
-            return false;
141
-        }
142
-        return wp_is_numeric_array($array);
143
-    }
144
-
145
-    /**
146
-     * @param bool $prefixed
147
-     * @return array
148
-     */
149
-    public static function prefixKeys(array $values, $prefixed = true)
150
-    {
151
-        $trim = '_';
152
-        $prefix = $prefixed
153
-            ? $trim
154
-            : '';
155
-        $prefixed = [];
156
-        foreach ($values as $key => $value) {
157
-            $key = trim($key);
158
-            if (0 === strpos($key, $trim)) {
159
-                $key = substr($key, strlen($trim));
160
-            }
161
-            $prefixed[$prefix.$key] = $value;
162
-        }
163
-        return $prefixed;
164
-    }
165
-
166
-    /**
167
-     * @return array
168
-     */
169
-    public static function removeEmptyValues(array $array)
170
-    {
171
-        $result = [];
172
-        foreach ($array as $key => $value) {
173
-            if (!$value) {
174
-                continue;
175
-            }
176
-            $result[$key] = is_array($value)
177
-                ? static::removeEmptyValues($value)
178
-                : $value;
179
-        }
180
-        return $result;
181
-    }
182
-
183
-
184
-    /**
185
-     * Set a value to an array of values using a dot-notation path as reference.
186
-     * @param string $path
187
-     * @param mixed $value
188
-     * @return array
189
-     */
190
-    public static function set(array $data, $path, $value)
191
-    {
192
-        $token = strtok($path, '.');
193
-        $ref = &$data;
194
-        while (false !== $token) {
195
-            $ref = static::consolidate($ref);
196
-            $ref = &$ref[$token];
197
-            $token = strtok('.');
198
-        }
199
-        $ref = $value;
200
-        return $data;
201
-    }
202
-
203
-    /**
204
-     * @return array
205
-     */
206
-    public static function unique(array $values)
207
-    {
208
-        return array_filter(array_unique($values));
209
-    }
210
-
211
-    /**
212
-     * @return array
213
-     */
214
-    public static function unprefixKeys(array $values)
215
-    {
216
-        return static::prefixKeys($values, false);
217
-    }
7
+	/**
8
+	 * @return bool
9
+	 */
10
+	public static function compare(array $arr1, array $arr2)
11
+	{
12
+		sort($arr1);
13
+		sort($arr2);
14
+		return $arr1 == $arr2;
15
+	}
16
+
17
+	/**
18
+	 * @param mixed $array
19
+	 * @return array
20
+	 */
21
+	public static function consolidate($array)
22
+	{
23
+		return is_array($array) || is_object($array)
24
+			? (array) $array
25
+			: [];
26
+	}
27
+
28
+	/**
29
+	 * @return array
30
+	 */
31
+	public static function convertFromDotNotation(array $array)
32
+	{
33
+		$results = [];
34
+		foreach ($array as $path => $value) {
35
+			$results = static::set($results, $path, $value);
36
+		}
37
+		return $results;
38
+	}
39
+
40
+	/**
41
+	 * @param string $string
42
+	 * @param mixed $callback
43
+	 * @return array
44
+	 */
45
+	public static function convertFromString($string, $callback = null)
46
+	{
47
+		$array = array_map('trim', explode(',', $string));
48
+		return $callback
49
+			? array_filter($array, $callback)
50
+			: array_filter($array);
51
+	}
52
+
53
+	/**
54
+	 * @param bool $flattenValue
55
+	 * @param string $prefix
56
+	 * @return array
57
+	 */
58
+	public static function flatten(array $array, $flattenValue = false, $prefix = '')
59
+	{
60
+		$result = [];
61
+		foreach ($array as $key => $value) {
62
+			$newKey = ltrim($prefix.'.'.$key, '.');
63
+			if (static::isIndexedAndFlat($value)) {
64
+				if ($flattenValue) {
65
+					$value = '['.implode(', ', $value).']';
66
+				}
67
+			} elseif (is_array($value)) {
68
+				$result = array_merge($result, static::flatten($value, $flattenValue, $newKey));
69
+				continue;
70
+			}
71
+			$result[$newKey] = $value;
72
+		}
73
+		return $result;
74
+	}
75
+
76
+	/**
77
+	 * Get a value from an array of values using a dot-notation path as reference.
78
+	 * @param mixed $data
79
+	 * @param string $path
80
+	 * @param mixed $fallback
81
+	 * @return mixed
82
+	 */
83
+	public static function get($data, $path = '', $fallback = '')
84
+	{
85
+		$data = static::consolidate($data);
86
+		$keys = explode('.', $path);
87
+		foreach ($keys as $key) {
88
+			if (!isset($data[$key])) {
89
+				return $fallback;
90
+			}
91
+			$data = $data[$key];
92
+		}
93
+		return $data;
94
+	}
95
+
96
+	/**
97
+	 * @param string $key
98
+	 * @return array
99
+	 */
100
+	public static function insertAfter($key, array $array, array $insert)
101
+	{
102
+		return static::insert($array, $insert, $key, 'after');
103
+	}
104
+
105
+	/**
106
+	 * @param string $key
107
+	 * @return array
108
+	 */
109
+	public static function insertBefore($key, array $array, array $insert)
110
+	{
111
+		return static::insert($array, $insert, $key, 'before');
112
+	}
113
+
114
+	/**
115
+	 * @param string $key
116
+	 * @param string $position
117
+	 * @return array
118
+	 */
119
+	public static function insert(array $array, array $insert, $key, $position = 'before')
120
+	{
121
+		$keyPosition = intval(array_search($key, array_keys($array)));
122
+		if ('after' == $position) {
123
+			++$keyPosition;
124
+		}
125
+		if (false !== $keyPosition) {
126
+			$result = array_slice($array, 0, $keyPosition);
127
+			$result = array_merge($result, $insert);
128
+			return array_merge($result, array_slice($array, $keyPosition));
129
+		}
130
+		return array_merge($array, $insert);
131
+	}
132
+
133
+	/**
134
+	 * @param mixed $array
135
+	 * @return bool
136
+	 */
137
+	public static function isIndexedAndFlat($array)
138
+	{
139
+		if (!is_array($array) || array_filter($array, 'is_array')) {
140
+			return false;
141
+		}
142
+		return wp_is_numeric_array($array);
143
+	}
144
+
145
+	/**
146
+	 * @param bool $prefixed
147
+	 * @return array
148
+	 */
149
+	public static function prefixKeys(array $values, $prefixed = true)
150
+	{
151
+		$trim = '_';
152
+		$prefix = $prefixed
153
+			? $trim
154
+			: '';
155
+		$prefixed = [];
156
+		foreach ($values as $key => $value) {
157
+			$key = trim($key);
158
+			if (0 === strpos($key, $trim)) {
159
+				$key = substr($key, strlen($trim));
160
+			}
161
+			$prefixed[$prefix.$key] = $value;
162
+		}
163
+		return $prefixed;
164
+	}
165
+
166
+	/**
167
+	 * @return array
168
+	 */
169
+	public static function removeEmptyValues(array $array)
170
+	{
171
+		$result = [];
172
+		foreach ($array as $key => $value) {
173
+			if (!$value) {
174
+				continue;
175
+			}
176
+			$result[$key] = is_array($value)
177
+				? static::removeEmptyValues($value)
178
+				: $value;
179
+		}
180
+		return $result;
181
+	}
182
+
183
+
184
+	/**
185
+	 * Set a value to an array of values using a dot-notation path as reference.
186
+	 * @param string $path
187
+	 * @param mixed $value
188
+	 * @return array
189
+	 */
190
+	public static function set(array $data, $path, $value)
191
+	{
192
+		$token = strtok($path, '.');
193
+		$ref = &$data;
194
+		while (false !== $token) {
195
+			$ref = static::consolidate($ref);
196
+			$ref = &$ref[$token];
197
+			$token = strtok('.');
198
+		}
199
+		$ref = $value;
200
+		return $data;
201
+	}
202
+
203
+	/**
204
+	 * @return array
205
+	 */
206
+	public static function unique(array $values)
207
+	{
208
+		return array_filter(array_unique($values));
209
+	}
210
+
211
+	/**
212
+	 * @return array
213
+	 */
214
+	public static function unprefixKeys(array $values)
215
+	{
216
+		return static::prefixKeys($values, false);
217
+	}
218 218
 }
Please login to merge, or discard this patch.
Spacing   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -7,10 +7,10 @@  discard block
 block discarded – undo
7 7
     /**
8 8
      * @return bool
9 9
      */
10
-    public static function compare(array $arr1, array $arr2)
10
+    public static function compare( array $arr1, array $arr2 )
11 11
     {
12
-        sort($arr1);
13
-        sort($arr2);
12
+        sort( $arr1 );
13
+        sort( $arr2 );
14 14
         return $arr1 == $arr2;
15 15
     }
16 16
 
@@ -18,21 +18,21 @@  discard block
 block discarded – undo
18 18
      * @param mixed $array
19 19
      * @return array
20 20
      */
21
-    public static function consolidate($array)
21
+    public static function consolidate( $array )
22 22
     {
23
-        return is_array($array) || is_object($array)
24
-            ? (array) $array
23
+        return is_array( $array ) || is_object( $array )
24
+            ? (array)$array
25 25
             : [];
26 26
     }
27 27
 
28 28
     /**
29 29
      * @return array
30 30
      */
31
-    public static function convertFromDotNotation(array $array)
31
+    public static function convertFromDotNotation( array $array )
32 32
     {
33 33
         $results = [];
34
-        foreach ($array as $path => $value) {
35
-            $results = static::set($results, $path, $value);
34
+        foreach( $array as $path => $value ) {
35
+            $results = static::set( $results, $path, $value );
36 36
         }
37 37
         return $results;
38 38
     }
@@ -42,12 +42,12 @@  discard block
 block discarded – undo
42 42
      * @param mixed $callback
43 43
      * @return array
44 44
      */
45
-    public static function convertFromString($string, $callback = null)
45
+    public static function convertFromString( $string, $callback = null )
46 46
     {
47
-        $array = array_map('trim', explode(',', $string));
47
+        $array = array_map( 'trim', explode( ',', $string ) );
48 48
         return $callback
49
-            ? array_filter($array, $callback)
50
-            : array_filter($array);
49
+            ? array_filter( $array, $callback )
50
+            : array_filter( $array );
51 51
     }
52 52
 
53 53
     /**
@@ -55,17 +55,17 @@  discard block
 block discarded – undo
55 55
      * @param string $prefix
56 56
      * @return array
57 57
      */
58
-    public static function flatten(array $array, $flattenValue = false, $prefix = '')
58
+    public static function flatten( array $array, $flattenValue = false, $prefix = '' )
59 59
     {
60 60
         $result = [];
61
-        foreach ($array as $key => $value) {
62
-            $newKey = ltrim($prefix.'.'.$key, '.');
63
-            if (static::isIndexedAndFlat($value)) {
64
-                if ($flattenValue) {
65
-                    $value = '['.implode(', ', $value).']';
61
+        foreach( $array as $key => $value ) {
62
+            $newKey = ltrim( $prefix.'.'.$key, '.' );
63
+            if( static::isIndexedAndFlat( $value ) ) {
64
+                if( $flattenValue ) {
65
+                    $value = '['.implode( ', ', $value ).']';
66 66
                 }
67
-            } elseif (is_array($value)) {
68
-                $result = array_merge($result, static::flatten($value, $flattenValue, $newKey));
67
+            } elseif( is_array( $value ) ) {
68
+                $result = array_merge( $result, static::flatten( $value, $flattenValue, $newKey ) );
69 69
                 continue;
70 70
             }
71 71
             $result[$newKey] = $value;
@@ -80,12 +80,12 @@  discard block
 block discarded – undo
80 80
      * @param mixed $fallback
81 81
      * @return mixed
82 82
      */
83
-    public static function get($data, $path = '', $fallback = '')
83
+    public static function get( $data, $path = '', $fallback = '' )
84 84
     {
85
-        $data = static::consolidate($data);
86
-        $keys = explode('.', $path);
87
-        foreach ($keys as $key) {
88
-            if (!isset($data[$key])) {
85
+        $data = static::consolidate( $data );
86
+        $keys = explode( '.', $path );
87
+        foreach( $keys as $key ) {
88
+            if( !isset($data[$key]) ) {
89 89
                 return $fallback;
90 90
             }
91 91
             $data = $data[$key];
@@ -97,18 +97,18 @@  discard block
 block discarded – undo
97 97
      * @param string $key
98 98
      * @return array
99 99
      */
100
-    public static function insertAfter($key, array $array, array $insert)
100
+    public static function insertAfter( $key, array $array, array $insert )
101 101
     {
102
-        return static::insert($array, $insert, $key, 'after');
102
+        return static::insert( $array, $insert, $key, 'after' );
103 103
     }
104 104
 
105 105
     /**
106 106
      * @param string $key
107 107
      * @return array
108 108
      */
109
-    public static function insertBefore($key, array $array, array $insert)
109
+    public static function insertBefore( $key, array $array, array $insert )
110 110
     {
111
-        return static::insert($array, $insert, $key, 'before');
111
+        return static::insert( $array, $insert, $key, 'before' );
112 112
     }
113 113
 
114 114
     /**
@@ -116,47 +116,47 @@  discard block
 block discarded – undo
116 116
      * @param string $position
117 117
      * @return array
118 118
      */
119
-    public static function insert(array $array, array $insert, $key, $position = 'before')
119
+    public static function insert( array $array, array $insert, $key, $position = 'before' )
120 120
     {
121
-        $keyPosition = intval(array_search($key, array_keys($array)));
122
-        if ('after' == $position) {
121
+        $keyPosition = intval( array_search( $key, array_keys( $array ) ) );
122
+        if( 'after' == $position ) {
123 123
             ++$keyPosition;
124 124
         }
125
-        if (false !== $keyPosition) {
126
-            $result = array_slice($array, 0, $keyPosition);
127
-            $result = array_merge($result, $insert);
128
-            return array_merge($result, array_slice($array, $keyPosition));
125
+        if( false !== $keyPosition ) {
126
+            $result = array_slice( $array, 0, $keyPosition );
127
+            $result = array_merge( $result, $insert );
128
+            return array_merge( $result, array_slice( $array, $keyPosition ) );
129 129
         }
130
-        return array_merge($array, $insert);
130
+        return array_merge( $array, $insert );
131 131
     }
132 132
 
133 133
     /**
134 134
      * @param mixed $array
135 135
      * @return bool
136 136
      */
137
-    public static function isIndexedAndFlat($array)
137
+    public static function isIndexedAndFlat( $array )
138 138
     {
139
-        if (!is_array($array) || array_filter($array, 'is_array')) {
139
+        if( !is_array( $array ) || array_filter( $array, 'is_array' ) ) {
140 140
             return false;
141 141
         }
142
-        return wp_is_numeric_array($array);
142
+        return wp_is_numeric_array( $array );
143 143
     }
144 144
 
145 145
     /**
146 146
      * @param bool $prefixed
147 147
      * @return array
148 148
      */
149
-    public static function prefixKeys(array $values, $prefixed = true)
149
+    public static function prefixKeys( array $values, $prefixed = true )
150 150
     {
151 151
         $trim = '_';
152 152
         $prefix = $prefixed
153 153
             ? $trim
154 154
             : '';
155 155
         $prefixed = [];
156
-        foreach ($values as $key => $value) {
157
-            $key = trim($key);
158
-            if (0 === strpos($key, $trim)) {
159
-                $key = substr($key, strlen($trim));
156
+        foreach( $values as $key => $value ) {
157
+            $key = trim( $key );
158
+            if( 0 === strpos( $key, $trim ) ) {
159
+                $key = substr( $key, strlen( $trim ) );
160 160
             }
161 161
             $prefixed[$prefix.$key] = $value;
162 162
         }
@@ -166,15 +166,15 @@  discard block
 block discarded – undo
166 166
     /**
167 167
      * @return array
168 168
      */
169
-    public static function removeEmptyValues(array $array)
169
+    public static function removeEmptyValues( array $array )
170 170
     {
171 171
         $result = [];
172
-        foreach ($array as $key => $value) {
173
-            if (!$value) {
172
+        foreach( $array as $key => $value ) {
173
+            if( !$value ) {
174 174
                 continue;
175 175
             }
176
-            $result[$key] = is_array($value)
177
-                ? static::removeEmptyValues($value)
176
+            $result[$key] = is_array( $value )
177
+                ? static::removeEmptyValues( $value )
178 178
                 : $value;
179 179
         }
180 180
         return $result;
@@ -187,14 +187,14 @@  discard block
 block discarded – undo
187 187
      * @param mixed $value
188 188
      * @return array
189 189
      */
190
-    public static function set(array $data, $path, $value)
190
+    public static function set( array $data, $path, $value )
191 191
     {
192
-        $token = strtok($path, '.');
192
+        $token = strtok( $path, '.' );
193 193
         $ref = &$data;
194
-        while (false !== $token) {
195
-            $ref = static::consolidate($ref);
194
+        while( false !== $token ) {
195
+            $ref = static::consolidate( $ref );
196 196
             $ref = &$ref[$token];
197
-            $token = strtok('.');
197
+            $token = strtok( '.' );
198 198
         }
199 199
         $ref = $value;
200 200
         return $data;
@@ -203,16 +203,16 @@  discard block
 block discarded – undo
203 203
     /**
204 204
      * @return array
205 205
      */
206
-    public static function unique(array $values)
206
+    public static function unique( array $values )
207 207
     {
208
-        return array_filter(array_unique($values));
208
+        return array_filter( array_unique( $values ) );
209 209
     }
210 210
 
211 211
     /**
212 212
      * @return array
213 213
      */
214
-    public static function unprefixKeys(array $values)
214
+    public static function unprefixKeys( array $values )
215 215
     {
216
-        return static::prefixKeys($values, false);
216
+        return static::prefixKeys( $values, false );
217 217
     }
218 218
 }
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -64,7 +64,8 @@
 block discarded – undo
64 64
                 if ($flattenValue) {
65 65
                     $value = '['.implode(', ', $value).']';
66 66
                 }
67
-            } elseif (is_array($value)) {
67
+            }
68
+            elseif (is_array($value)) {
68 69
                 $result = array_merge($result, static::flatten($value, $flattenValue, $newKey));
69 70
                 continue;
70 71
             }
Please login to merge, or discard this patch.
plugin/Widgets/SiteReviewsSummaryWidget.php 2 patches
Indentation   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -7,58 +7,58 @@
 block discarded – undo
7 7
 
8 8
 class SiteReviewsSummaryWidget extends Widget
9 9
 {
10
-    /**
11
-     * @param array $instance
12
-     * @return void
13
-     */
14
-    public function form($instance)
15
-    {
16
-        $this->widgetArgs = $this->shortcode()->normalizeAtts($instance);
17
-        $terms = glsr(Database::class)->getTerms();
18
-        $this->renderField('text', [
19
-            'class' => 'widefat',
20
-            'label' => __('Title', 'site-reviews'),
21
-            'name' => 'title',
22
-        ]);
23
-        if (count(glsr()->reviewTypes) > 1) {
24
-            $this->renderField('select', [
25
-                'class' => 'widefat',
26
-                'label' => __('Which type of review would you like to use?', 'site-reviews'),
27
-                'name' => 'type',
28
-                'options' => ['' => __('All review types', 'site-reviews')] + glsr()->reviewTypes,
29
-            ]);
30
-        }
31
-        if (!empty($terms)) {
32
-            $this->renderField('select', [
33
-                'class' => 'widefat',
34
-                'label' => __('Limit summary to this category', 'site-reviews'),
35
-                'name' => 'category',
36
-                'options' => ['' => __('All Categories', 'site-reviews')] + $terms,
37
-            ]);
38
-        }
39
-        $this->renderField('text', [
40
-            'class' => 'widefat',
41
-            'default' => '',
42
-            'description' => sprintf(__("Separate multiple ID's with a comma. You may also enter %s to automatically represent the current page/post ID.", 'site-reviews'), '<code>post_id</code>'),
43
-            'label' => __('Limit summary to reviews assigned to a page/post ID', 'site-reviews'),
44
-            'name' => 'assigned_to',
45
-        ]);
46
-        $this->renderField('text', [
47
-            'class' => 'widefat',
48
-            'label' => __('Enter any custom CSS classes here', 'site-reviews'),
49
-            'name' => 'class',
50
-        ]);
51
-        $this->renderField('checkbox', [
52
-            'name' => 'hide',
53
-            'options' => $this->shortcode()->getHideOptions(),
54
-        ]);
55
-    }
10
+	/**
11
+	 * @param array $instance
12
+	 * @return void
13
+	 */
14
+	public function form($instance)
15
+	{
16
+		$this->widgetArgs = $this->shortcode()->normalizeAtts($instance);
17
+		$terms = glsr(Database::class)->getTerms();
18
+		$this->renderField('text', [
19
+			'class' => 'widefat',
20
+			'label' => __('Title', 'site-reviews'),
21
+			'name' => 'title',
22
+		]);
23
+		if (count(glsr()->reviewTypes) > 1) {
24
+			$this->renderField('select', [
25
+				'class' => 'widefat',
26
+				'label' => __('Which type of review would you like to use?', 'site-reviews'),
27
+				'name' => 'type',
28
+				'options' => ['' => __('All review types', 'site-reviews')] + glsr()->reviewTypes,
29
+			]);
30
+		}
31
+		if (!empty($terms)) {
32
+			$this->renderField('select', [
33
+				'class' => 'widefat',
34
+				'label' => __('Limit summary to this category', 'site-reviews'),
35
+				'name' => 'category',
36
+				'options' => ['' => __('All Categories', 'site-reviews')] + $terms,
37
+			]);
38
+		}
39
+		$this->renderField('text', [
40
+			'class' => 'widefat',
41
+			'default' => '',
42
+			'description' => sprintf(__("Separate multiple ID's with a comma. You may also enter %s to automatically represent the current page/post ID.", 'site-reviews'), '<code>post_id</code>'),
43
+			'label' => __('Limit summary to reviews assigned to a page/post ID', 'site-reviews'),
44
+			'name' => 'assigned_to',
45
+		]);
46
+		$this->renderField('text', [
47
+			'class' => 'widefat',
48
+			'label' => __('Enter any custom CSS classes here', 'site-reviews'),
49
+			'name' => 'class',
50
+		]);
51
+		$this->renderField('checkbox', [
52
+			'name' => 'hide',
53
+			'options' => $this->shortcode()->getHideOptions(),
54
+		]);
55
+	}
56 56
 
57
-    /**
58
-     * {@inheritdoc}
59
-     */
60
-    protected function shortcode()
61
-    {
62
-        return glsr(SiteReviewsSummaryShortcode::class);
63
-    }
57
+	/**
58
+	 * {@inheritdoc}
59
+	 */
60
+	protected function shortcode()
61
+	{
62
+		return glsr(SiteReviewsSummaryShortcode::class);
63
+	}
64 64
 }
Please login to merge, or discard this patch.
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -11,47 +11,47 @@  discard block
 block discarded – undo
11 11
      * @param array $instance
12 12
      * @return void
13 13
      */
14
-    public function form($instance)
14
+    public function form( $instance )
15 15
     {
16
-        $this->widgetArgs = $this->shortcode()->normalizeAtts($instance);
17
-        $terms = glsr(Database::class)->getTerms();
18
-        $this->renderField('text', [
16
+        $this->widgetArgs = $this->shortcode()->normalizeAtts( $instance );
17
+        $terms = glsr( Database::class )->getTerms();
18
+        $this->renderField( 'text', [
19 19
             'class' => 'widefat',
20
-            'label' => __('Title', 'site-reviews'),
20
+            'label' => __( 'Title', 'site-reviews' ),
21 21
             'name' => 'title',
22
-        ]);
23
-        if (count(glsr()->reviewTypes) > 1) {
24
-            $this->renderField('select', [
22
+        ] );
23
+        if( count( glsr()->reviewTypes ) > 1 ) {
24
+            $this->renderField( 'select', [
25 25
                 'class' => 'widefat',
26
-                'label' => __('Which type of review would you like to use?', 'site-reviews'),
26
+                'label' => __( 'Which type of review would you like to use?', 'site-reviews' ),
27 27
                 'name' => 'type',
28
-                'options' => ['' => __('All review types', 'site-reviews')] + glsr()->reviewTypes,
29
-            ]);
28
+                'options' => ['' => __( 'All review types', 'site-reviews' )] + glsr()->reviewTypes,
29
+            ] );
30 30
         }
31
-        if (!empty($terms)) {
32
-            $this->renderField('select', [
31
+        if( !empty($terms) ) {
32
+            $this->renderField( 'select', [
33 33
                 'class' => 'widefat',
34
-                'label' => __('Limit summary to this category', 'site-reviews'),
34
+                'label' => __( 'Limit summary to this category', 'site-reviews' ),
35 35
                 'name' => 'category',
36
-                'options' => ['' => __('All Categories', 'site-reviews')] + $terms,
37
-            ]);
36
+                'options' => ['' => __( 'All Categories', 'site-reviews' )] + $terms,
37
+            ] );
38 38
         }
39
-        $this->renderField('text', [
39
+        $this->renderField( 'text', [
40 40
             'class' => 'widefat',
41 41
             'default' => '',
42
-            'description' => sprintf(__("Separate multiple ID's with a comma. You may also enter %s to automatically represent the current page/post ID.", 'site-reviews'), '<code>post_id</code>'),
43
-            'label' => __('Limit summary to reviews assigned to a page/post ID', 'site-reviews'),
42
+            'description' => sprintf( __( "Separate multiple ID's with a comma. You may also enter %s to automatically represent the current page/post ID.", 'site-reviews' ), '<code>post_id</code>' ),
43
+            'label' => __( 'Limit summary to reviews assigned to a page/post ID', 'site-reviews' ),
44 44
             'name' => 'assigned_to',
45
-        ]);
46
-        $this->renderField('text', [
45
+        ] );
46
+        $this->renderField( 'text', [
47 47
             'class' => 'widefat',
48
-            'label' => __('Enter any custom CSS classes here', 'site-reviews'),
48
+            'label' => __( 'Enter any custom CSS classes here', 'site-reviews' ),
49 49
             'name' => 'class',
50
-        ]);
51
-        $this->renderField('checkbox', [
50
+        ] );
51
+        $this->renderField( 'checkbox', [
52 52
             'name' => 'hide',
53 53
             'options' => $this->shortcode()->getHideOptions(),
54
-        ]);
54
+        ] );
55 55
     }
56 56
 
57 57
     /**
@@ -59,6 +59,6 @@  discard block
 block discarded – undo
59 59
      */
60 60
     protected function shortcode()
61 61
     {
62
-        return glsr(SiteReviewsSummaryShortcode::class);
62
+        return glsr( SiteReviewsSummaryShortcode::class );
63 63
     }
64 64
 }
Please login to merge, or discard this patch.
plugin/Widgets/SiteReviewsWidget.php 2 patches
Indentation   +85 added lines, -85 removed lines patch added patch discarded remove patch
@@ -7,91 +7,91 @@
 block discarded – undo
7 7
 
8 8
 class SiteReviewsWidget extends Widget
9 9
 {
10
-    /**
11
-     * @param array $instance
12
-     * @return void
13
-     */
14
-    public function form($instance)
15
-    {
16
-        $this->widgetArgs = $this->shortcode()->normalizeAtts($instance);
17
-        $terms = glsr(Database::class)->getTerms();
18
-        $this->renderField('text', [
19
-            'class' => 'widefat',
20
-            'label' => __('Title', 'site-reviews'),
21
-            'name' => 'title',
22
-        ]);
23
-        $this->renderField('number', [
24
-            'class' => 'small-text',
25
-            'default' => 10,
26
-            'label' => __('How many reviews would you like to display?', 'site-reviews'),
27
-            'max' => 100,
28
-            'name' => 'display',
29
-        ]);
30
-        $this->renderField('select', [
31
-            'label' => __('What is the minimum rating to display?', 'site-reviews'),
32
-            'name' => 'rating',
33
-            'options' => [
34
-                '0' => sprintf(_n('%s star', '%s stars', 0, 'site-reviews'), 0),
35
-                '1' => sprintf(_n('%s star', '%s stars', 1, 'site-reviews'), 1),
36
-                '2' => sprintf(_n('%s star', '%s stars', 2, 'site-reviews'), 2),
37
-                '3' => sprintf(_n('%s star', '%s stars', 3, 'site-reviews'), 3),
38
-                '4' => sprintf(_n('%s star', '%s stars', 4, 'site-reviews'), 4),
39
-                '5' => sprintf(_n('%s star', '%s stars', 5, 'site-reviews'), 5),
40
-            ],
41
-        ]);
42
-        if (count(glsr()->reviewTypes) > 1) {
43
-            $this->renderField('select', [
44
-                'class' => 'widefat',
45
-                'label' => __('Which type of review would you like to display?', 'site-reviews'),
46
-                'name' => 'type',
47
-                'options' => ['' => __('All Reviews', 'site-reviews')] + glsr()->reviewTypes,
48
-            ]);
49
-        }
50
-        if (!empty($terms)) {
51
-            $this->renderField('select', [
52
-                'class' => 'widefat',
53
-                'label' => __('Limit reviews to this category', 'site-reviews'),
54
-                'name' => 'category',
55
-                'options' => ['' => __('All Categories', 'site-reviews')] + $terms,
56
-            ]);
57
-        }
58
-        $this->renderField('text', [
59
-            'class' => 'widefat',
60
-            'default' => '',
61
-            'description' => sprintf(__("Separate multiple ID's with a comma. You may also enter %s to automatically represent the current page/post ID.", 'site-reviews'), '<code>post_id</code>'),
62
-            'label' => __('Limit reviews to those assigned to this page/post ID', 'site-reviews'),
63
-            'name' => 'assigned_to',
64
-        ]);
65
-        $this->renderField('text', [
66
-            'class' => 'widefat',
67
-            'label' => __('Enter any custom CSS classes here', 'site-reviews'),
68
-            'name' => 'class',
69
-        ]);
70
-        $this->renderField('checkbox', [
71
-            'name' => 'hide',
72
-            'options' => $this->shortcode()->getHideOptions(),
73
-        ]);
74
-    }
10
+	/**
11
+	 * @param array $instance
12
+	 * @return void
13
+	 */
14
+	public function form($instance)
15
+	{
16
+		$this->widgetArgs = $this->shortcode()->normalizeAtts($instance);
17
+		$terms = glsr(Database::class)->getTerms();
18
+		$this->renderField('text', [
19
+			'class' => 'widefat',
20
+			'label' => __('Title', 'site-reviews'),
21
+			'name' => 'title',
22
+		]);
23
+		$this->renderField('number', [
24
+			'class' => 'small-text',
25
+			'default' => 10,
26
+			'label' => __('How many reviews would you like to display?', 'site-reviews'),
27
+			'max' => 100,
28
+			'name' => 'display',
29
+		]);
30
+		$this->renderField('select', [
31
+			'label' => __('What is the minimum rating to display?', 'site-reviews'),
32
+			'name' => 'rating',
33
+			'options' => [
34
+				'0' => sprintf(_n('%s star', '%s stars', 0, 'site-reviews'), 0),
35
+				'1' => sprintf(_n('%s star', '%s stars', 1, 'site-reviews'), 1),
36
+				'2' => sprintf(_n('%s star', '%s stars', 2, 'site-reviews'), 2),
37
+				'3' => sprintf(_n('%s star', '%s stars', 3, 'site-reviews'), 3),
38
+				'4' => sprintf(_n('%s star', '%s stars', 4, 'site-reviews'), 4),
39
+				'5' => sprintf(_n('%s star', '%s stars', 5, 'site-reviews'), 5),
40
+			],
41
+		]);
42
+		if (count(glsr()->reviewTypes) > 1) {
43
+			$this->renderField('select', [
44
+				'class' => 'widefat',
45
+				'label' => __('Which type of review would you like to display?', 'site-reviews'),
46
+				'name' => 'type',
47
+				'options' => ['' => __('All Reviews', 'site-reviews')] + glsr()->reviewTypes,
48
+			]);
49
+		}
50
+		if (!empty($terms)) {
51
+			$this->renderField('select', [
52
+				'class' => 'widefat',
53
+				'label' => __('Limit reviews to this category', 'site-reviews'),
54
+				'name' => 'category',
55
+				'options' => ['' => __('All Categories', 'site-reviews')] + $terms,
56
+			]);
57
+		}
58
+		$this->renderField('text', [
59
+			'class' => 'widefat',
60
+			'default' => '',
61
+			'description' => sprintf(__("Separate multiple ID's with a comma. You may also enter %s to automatically represent the current page/post ID.", 'site-reviews'), '<code>post_id</code>'),
62
+			'label' => __('Limit reviews to those assigned to this page/post ID', 'site-reviews'),
63
+			'name' => 'assigned_to',
64
+		]);
65
+		$this->renderField('text', [
66
+			'class' => 'widefat',
67
+			'label' => __('Enter any custom CSS classes here', 'site-reviews'),
68
+			'name' => 'class',
69
+		]);
70
+		$this->renderField('checkbox', [
71
+			'name' => 'hide',
72
+			'options' => $this->shortcode()->getHideOptions(),
73
+		]);
74
+	}
75 75
 
76
-    /**
77
-     * @param array $newInstance
78
-     * @param array $oldInstance
79
-     * @return array
80
-     */
81
-    public function update($newInstance, $oldInstance)
82
-    {
83
-        if (!is_numeric($newInstance['display'])) {
84
-            $newInstance['display'] = 10;
85
-        }
86
-        $newInstance['display'] = min(50, max(0, intval($newInstance['display'])));
87
-        return parent::update($newInstance, $oldInstance);
88
-    }
76
+	/**
77
+	 * @param array $newInstance
78
+	 * @param array $oldInstance
79
+	 * @return array
80
+	 */
81
+	public function update($newInstance, $oldInstance)
82
+	{
83
+		if (!is_numeric($newInstance['display'])) {
84
+			$newInstance['display'] = 10;
85
+		}
86
+		$newInstance['display'] = min(50, max(0, intval($newInstance['display'])));
87
+		return parent::update($newInstance, $oldInstance);
88
+	}
89 89
 
90
-    /**
91
-     * {@inheritdoc}
92
-     */
93
-    protected function shortcode()
94
-    {
95
-        return glsr(SiteReviewsShortcode::class);
96
-    }
90
+	/**
91
+	 * {@inheritdoc}
92
+	 */
93
+	protected function shortcode()
94
+	{
95
+		return glsr(SiteReviewsShortcode::class);
96
+	}
97 97
 }
Please login to merge, or discard this patch.
Spacing   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -11,66 +11,66 @@  discard block
 block discarded – undo
11 11
      * @param array $instance
12 12
      * @return void
13 13
      */
14
-    public function form($instance)
14
+    public function form( $instance )
15 15
     {
16
-        $this->widgetArgs = $this->shortcode()->normalizeAtts($instance);
17
-        $terms = glsr(Database::class)->getTerms();
18
-        $this->renderField('text', [
16
+        $this->widgetArgs = $this->shortcode()->normalizeAtts( $instance );
17
+        $terms = glsr( Database::class )->getTerms();
18
+        $this->renderField( 'text', [
19 19
             'class' => 'widefat',
20
-            'label' => __('Title', 'site-reviews'),
20
+            'label' => __( 'Title', 'site-reviews' ),
21 21
             'name' => 'title',
22
-        ]);
23
-        $this->renderField('number', [
22
+        ] );
23
+        $this->renderField( 'number', [
24 24
             'class' => 'small-text',
25 25
             'default' => 10,
26
-            'label' => __('How many reviews would you like to display?', 'site-reviews'),
26
+            'label' => __( 'How many reviews would you like to display?', 'site-reviews' ),
27 27
             'max' => 100,
28 28
             'name' => 'display',
29
-        ]);
30
-        $this->renderField('select', [
31
-            'label' => __('What is the minimum rating to display?', 'site-reviews'),
29
+        ] );
30
+        $this->renderField( 'select', [
31
+            'label' => __( 'What is the minimum rating to display?', 'site-reviews' ),
32 32
             'name' => 'rating',
33 33
             'options' => [
34
-                '0' => sprintf(_n('%s star', '%s stars', 0, 'site-reviews'), 0),
35
-                '1' => sprintf(_n('%s star', '%s stars', 1, 'site-reviews'), 1),
36
-                '2' => sprintf(_n('%s star', '%s stars', 2, 'site-reviews'), 2),
37
-                '3' => sprintf(_n('%s star', '%s stars', 3, 'site-reviews'), 3),
38
-                '4' => sprintf(_n('%s star', '%s stars', 4, 'site-reviews'), 4),
39
-                '5' => sprintf(_n('%s star', '%s stars', 5, 'site-reviews'), 5),
34
+                '0' => sprintf( _n( '%s star', '%s stars', 0, 'site-reviews' ), 0 ),
35
+                '1' => sprintf( _n( '%s star', '%s stars', 1, 'site-reviews' ), 1 ),
36
+                '2' => sprintf( _n( '%s star', '%s stars', 2, 'site-reviews' ), 2 ),
37
+                '3' => sprintf( _n( '%s star', '%s stars', 3, 'site-reviews' ), 3 ),
38
+                '4' => sprintf( _n( '%s star', '%s stars', 4, 'site-reviews' ), 4 ),
39
+                '5' => sprintf( _n( '%s star', '%s stars', 5, 'site-reviews' ), 5 ),
40 40
             ],
41
-        ]);
42
-        if (count(glsr()->reviewTypes) > 1) {
43
-            $this->renderField('select', [
41
+        ] );
42
+        if( count( glsr()->reviewTypes ) > 1 ) {
43
+            $this->renderField( 'select', [
44 44
                 'class' => 'widefat',
45
-                'label' => __('Which type of review would you like to display?', 'site-reviews'),
45
+                'label' => __( 'Which type of review would you like to display?', 'site-reviews' ),
46 46
                 'name' => 'type',
47
-                'options' => ['' => __('All Reviews', 'site-reviews')] + glsr()->reviewTypes,
48
-            ]);
47
+                'options' => ['' => __( 'All Reviews', 'site-reviews' )] + glsr()->reviewTypes,
48
+            ] );
49 49
         }
50
-        if (!empty($terms)) {
51
-            $this->renderField('select', [
50
+        if( !empty($terms) ) {
51
+            $this->renderField( 'select', [
52 52
                 'class' => 'widefat',
53
-                'label' => __('Limit reviews to this category', 'site-reviews'),
53
+                'label' => __( 'Limit reviews to this category', 'site-reviews' ),
54 54
                 'name' => 'category',
55
-                'options' => ['' => __('All Categories', 'site-reviews')] + $terms,
56
-            ]);
55
+                'options' => ['' => __( 'All Categories', 'site-reviews' )] + $terms,
56
+            ] );
57 57
         }
58
-        $this->renderField('text', [
58
+        $this->renderField( 'text', [
59 59
             'class' => 'widefat',
60 60
             'default' => '',
61
-            'description' => sprintf(__("Separate multiple ID's with a comma. You may also enter %s to automatically represent the current page/post ID.", 'site-reviews'), '<code>post_id</code>'),
62
-            'label' => __('Limit reviews to those assigned to this page/post ID', 'site-reviews'),
61
+            'description' => sprintf( __( "Separate multiple ID's with a comma. You may also enter %s to automatically represent the current page/post ID.", 'site-reviews' ), '<code>post_id</code>' ),
62
+            'label' => __( 'Limit reviews to those assigned to this page/post ID', 'site-reviews' ),
63 63
             'name' => 'assigned_to',
64
-        ]);
65
-        $this->renderField('text', [
64
+        ] );
65
+        $this->renderField( 'text', [
66 66
             'class' => 'widefat',
67
-            'label' => __('Enter any custom CSS classes here', 'site-reviews'),
67
+            'label' => __( 'Enter any custom CSS classes here', 'site-reviews' ),
68 68
             'name' => 'class',
69
-        ]);
70
-        $this->renderField('checkbox', [
69
+        ] );
70
+        $this->renderField( 'checkbox', [
71 71
             'name' => 'hide',
72 72
             'options' => $this->shortcode()->getHideOptions(),
73
-        ]);
73
+        ] );
74 74
     }
75 75
 
76 76
     /**
@@ -78,13 +78,13 @@  discard block
 block discarded – undo
78 78
      * @param array $oldInstance
79 79
      * @return array
80 80
      */
81
-    public function update($newInstance, $oldInstance)
81
+    public function update( $newInstance, $oldInstance )
82 82
     {
83
-        if (!is_numeric($newInstance['display'])) {
83
+        if( !is_numeric( $newInstance['display'] ) ) {
84 84
             $newInstance['display'] = 10;
85 85
         }
86
-        $newInstance['display'] = min(50, max(0, intval($newInstance['display'])));
87
-        return parent::update($newInstance, $oldInstance);
86
+        $newInstance['display'] = min( 50, max( 0, intval( $newInstance['display'] ) ) );
87
+        return parent::update( $newInstance, $oldInstance );
88 88
     }
89 89
 
90 90
     /**
@@ -92,6 +92,6 @@  discard block
 block discarded – undo
92 92
      */
93 93
     protected function shortcode()
94 94
     {
95
-        return glsr(SiteReviewsShortcode::class);
95
+        return glsr( SiteReviewsShortcode::class );
96 96
     }
97 97
 }
Please login to merge, or discard this patch.
plugin/Widgets/SiteReviewsFormWidget.php 2 patches
Indentation   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -7,53 +7,53 @@
 block discarded – undo
7 7
 
8 8
 class SiteReviewsFormWidget extends Widget
9 9
 {
10
-    /**
11
-     * @param array $instance
12
-     * @return void
13
-     */
14
-    public function form($instance)
15
-    {
16
-        $this->widgetArgs = $this->shortcode()->normalizeAtts($instance);
17
-        $terms = glsr(Database::class)->getTerms();
18
-        $this->renderField('text', [
19
-            'class' => 'widefat',
20
-            'label' => __('Title', 'site-reviews'),
21
-            'name' => 'title',
22
-        ]);
23
-        $this->renderField('textarea', [
24
-            'class' => 'widefat',
25
-            'label' => __('Description', 'site-reviews'),
26
-            'name' => 'description',
27
-        ]);
28
-        $this->renderField('select', [
29
-            'class' => 'widefat',
30
-            'label' => __('Automatically assign a category', 'site-reviews'),
31
-            'name' => 'category',
32
-            'options' => ['' => __('Do not assign a category', 'site-reviews')] + $terms,
33
-        ]);
34
-        $this->renderField('text', [
35
-            'class' => 'widefat',
36
-            'default' => '',
37
-            'description' => sprintf(__('You may also enter %s to assign to the current post.', 'site-reviews'), '<code>post_id</code>'),
38
-            'label' => __('Assign reviews to a custom page/post ID', 'site-reviews'),
39
-            'name' => 'assign_to',
40
-        ]);
41
-        $this->renderField('text', [
42
-            'class' => 'widefat',
43
-            'label' => __('Enter any custom CSS classes here', 'site-reviews'),
44
-            'name' => 'class',
45
-        ]);
46
-        $this->renderField('checkbox', [
47
-            'name' => 'hide',
48
-            'options' => $this->shortcode()->getHideOptions(),
49
-        ]);
50
-    }
10
+	/**
11
+	 * @param array $instance
12
+	 * @return void
13
+	 */
14
+	public function form($instance)
15
+	{
16
+		$this->widgetArgs = $this->shortcode()->normalizeAtts($instance);
17
+		$terms = glsr(Database::class)->getTerms();
18
+		$this->renderField('text', [
19
+			'class' => 'widefat',
20
+			'label' => __('Title', 'site-reviews'),
21
+			'name' => 'title',
22
+		]);
23
+		$this->renderField('textarea', [
24
+			'class' => 'widefat',
25
+			'label' => __('Description', 'site-reviews'),
26
+			'name' => 'description',
27
+		]);
28
+		$this->renderField('select', [
29
+			'class' => 'widefat',
30
+			'label' => __('Automatically assign a category', 'site-reviews'),
31
+			'name' => 'category',
32
+			'options' => ['' => __('Do not assign a category', 'site-reviews')] + $terms,
33
+		]);
34
+		$this->renderField('text', [
35
+			'class' => 'widefat',
36
+			'default' => '',
37
+			'description' => sprintf(__('You may also enter %s to assign to the current post.', 'site-reviews'), '<code>post_id</code>'),
38
+			'label' => __('Assign reviews to a custom page/post ID', 'site-reviews'),
39
+			'name' => 'assign_to',
40
+		]);
41
+		$this->renderField('text', [
42
+			'class' => 'widefat',
43
+			'label' => __('Enter any custom CSS classes here', 'site-reviews'),
44
+			'name' => 'class',
45
+		]);
46
+		$this->renderField('checkbox', [
47
+			'name' => 'hide',
48
+			'options' => $this->shortcode()->getHideOptions(),
49
+		]);
50
+	}
51 51
 
52
-    /**
53
-     * {@inheritdoc}
54
-     */
55
-    protected function shortcode()
56
-    {
57
-        return glsr(SiteReviewsFormShortcode::class);
58
-    }
52
+	/**
53
+	 * {@inheritdoc}
54
+	 */
55
+	protected function shortcode()
56
+	{
57
+		return glsr(SiteReviewsFormShortcode::class);
58
+	}
59 59
 }
Please login to merge, or discard this patch.
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -11,42 +11,42 @@  discard block
 block discarded – undo
11 11
      * @param array $instance
12 12
      * @return void
13 13
      */
14
-    public function form($instance)
14
+    public function form( $instance )
15 15
     {
16
-        $this->widgetArgs = $this->shortcode()->normalizeAtts($instance);
17
-        $terms = glsr(Database::class)->getTerms();
18
-        $this->renderField('text', [
16
+        $this->widgetArgs = $this->shortcode()->normalizeAtts( $instance );
17
+        $terms = glsr( Database::class )->getTerms();
18
+        $this->renderField( 'text', [
19 19
             'class' => 'widefat',
20
-            'label' => __('Title', 'site-reviews'),
20
+            'label' => __( 'Title', 'site-reviews' ),
21 21
             'name' => 'title',
22
-        ]);
23
-        $this->renderField('textarea', [
22
+        ] );
23
+        $this->renderField( 'textarea', [
24 24
             'class' => 'widefat',
25
-            'label' => __('Description', 'site-reviews'),
25
+            'label' => __( 'Description', 'site-reviews' ),
26 26
             'name' => 'description',
27
-        ]);
28
-        $this->renderField('select', [
27
+        ] );
28
+        $this->renderField( 'select', [
29 29
             'class' => 'widefat',
30
-            'label' => __('Automatically assign a category', 'site-reviews'),
30
+            'label' => __( 'Automatically assign a category', 'site-reviews' ),
31 31
             'name' => 'category',
32
-            'options' => ['' => __('Do not assign a category', 'site-reviews')] + $terms,
33
-        ]);
34
-        $this->renderField('text', [
32
+            'options' => ['' => __( 'Do not assign a category', 'site-reviews' )] + $terms,
33
+        ] );
34
+        $this->renderField( 'text', [
35 35
             'class' => 'widefat',
36 36
             'default' => '',
37
-            'description' => sprintf(__('You may also enter %s to assign to the current post.', 'site-reviews'), '<code>post_id</code>'),
38
-            'label' => __('Assign reviews to a custom page/post ID', 'site-reviews'),
37
+            'description' => sprintf( __( 'You may also enter %s to assign to the current post.', 'site-reviews' ), '<code>post_id</code>' ),
38
+            'label' => __( 'Assign reviews to a custom page/post ID', 'site-reviews' ),
39 39
             'name' => 'assign_to',
40
-        ]);
41
-        $this->renderField('text', [
40
+        ] );
41
+        $this->renderField( 'text', [
42 42
             'class' => 'widefat',
43
-            'label' => __('Enter any custom CSS classes here', 'site-reviews'),
43
+            'label' => __( 'Enter any custom CSS classes here', 'site-reviews' ),
44 44
             'name' => 'class',
45
-        ]);
46
-        $this->renderField('checkbox', [
45
+        ] );
46
+        $this->renderField( 'checkbox', [
47 47
             'name' => 'hide',
48 48
             'options' => $this->shortcode()->getHideOptions(),
49
-        ]);
49
+        ] );
50 50
     }
51 51
 
52 52
     /**
@@ -54,6 +54,6 @@  discard block
 block discarded – undo
54 54
      */
55 55
     protected function shortcode()
56 56
     {
57
-        return glsr(SiteReviewsFormShortcode::class);
57
+        return glsr( SiteReviewsFormShortcode::class );
58 58
     }
59 59
 }
Please login to merge, or discard this patch.
plugin/Widgets/Widget.php 2 patches
Indentation   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -7,54 +7,54 @@
 block discarded – undo
7 7
 
8 8
 abstract class Widget extends WP_Widget
9 9
 {
10
-    /**
11
-     * @var array
12
-     */
13
-    protected $widgetArgs;
10
+	/**
11
+	 * @var array
12
+	 */
13
+	protected $widgetArgs;
14 14
 
15
-    /**
16
-     * @param array $args
17
-     * @param array $instance
18
-     * @return void
19
-     */
20
-    public function widget($args, $instance)
21
-    {
22
-        echo $this->shortcode()->build($instance, $args, 'widget');
23
-    }
15
+	/**
16
+	 * @param array $args
17
+	 * @param array $instance
18
+	 * @return void
19
+	 */
20
+	public function widget($args, $instance)
21
+	{
22
+		echo $this->shortcode()->build($instance, $args, 'widget');
23
+	}
24 24
 
25
-    /**
26
-     * @param string $tag
27
-     * @return array
28
-     */
29
-    protected function normalizeFieldAttributes($tag, array $args)
30
-    {
31
-        if (empty($args['value'])) {
32
-            $args['value'] = $this->widgetArgs[$args['name']];
33
-        }
34
-        if (empty($this->widgetArgs['options']) && in_array($tag, ['checkbox', 'radio'])) {
35
-            $args['checked'] = in_array($args['value'], (array) $this->widgetArgs[$args['name']]);
36
-        }
37
-        $args['id'] = $this->get_field_id($args['name']);
38
-        $args['name'] = $this->get_field_name($args['name']);
39
-        $args['is_widget'] = true;
40
-        return $args;
41
-    }
25
+	/**
26
+	 * @param string $tag
27
+	 * @return array
28
+	 */
29
+	protected function normalizeFieldAttributes($tag, array $args)
30
+	{
31
+		if (empty($args['value'])) {
32
+			$args['value'] = $this->widgetArgs[$args['name']];
33
+		}
34
+		if (empty($this->widgetArgs['options']) && in_array($tag, ['checkbox', 'radio'])) {
35
+			$args['checked'] = in_array($args['value'], (array) $this->widgetArgs[$args['name']]);
36
+		}
37
+		$args['id'] = $this->get_field_id($args['name']);
38
+		$args['name'] = $this->get_field_name($args['name']);
39
+		$args['is_widget'] = true;
40
+		return $args;
41
+	}
42 42
 
43
-    /**
44
-     * @param string $tag
45
-     * @return void
46
-     */
47
-    protected function renderField($tag, array $args = [])
48
-    {
49
-        $args = $this->normalizeFieldAttributes($tag, $args);
50
-        $field = glsr(Builder::class)->$tag($args['name'], $args);
51
-        echo glsr(Builder::class)->div($field, [
52
-            'class' => 'glsr-field',
53
-        ]);
54
-    }
43
+	/**
44
+	 * @param string $tag
45
+	 * @return void
46
+	 */
47
+	protected function renderField($tag, array $args = [])
48
+	{
49
+		$args = $this->normalizeFieldAttributes($tag, $args);
50
+		$field = glsr(Builder::class)->$tag($args['name'], $args);
51
+		echo glsr(Builder::class)->div($field, [
52
+			'class' => 'glsr-field',
53
+		]);
54
+	}
55 55
 
56
-    /**
57
-     * @return \GeminiLabs\SiteReviews\Shortcodes\Shortcode
58
-     */
59
-    abstract protected function shortcode();
56
+	/**
57
+	 * @return \GeminiLabs\SiteReviews\Shortcodes\Shortcode
58
+	 */
59
+	abstract protected function shortcode();
60 60
 }
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -17,25 +17,25 @@  discard block
 block discarded – undo
17 17
      * @param array $instance
18 18
      * @return void
19 19
      */
20
-    public function widget($args, $instance)
20
+    public function widget( $args, $instance )
21 21
     {
22
-        echo $this->shortcode()->build($instance, $args, 'widget');
22
+        echo $this->shortcode()->build( $instance, $args, 'widget' );
23 23
     }
24 24
 
25 25
     /**
26 26
      * @param string $tag
27 27
      * @return array
28 28
      */
29
-    protected function normalizeFieldAttributes($tag, array $args)
29
+    protected function normalizeFieldAttributes( $tag, array $args )
30 30
     {
31
-        if (empty($args['value'])) {
31
+        if( empty($args['value']) ) {
32 32
             $args['value'] = $this->widgetArgs[$args['name']];
33 33
         }
34
-        if (empty($this->widgetArgs['options']) && in_array($tag, ['checkbox', 'radio'])) {
35
-            $args['checked'] = in_array($args['value'], (array) $this->widgetArgs[$args['name']]);
34
+        if( empty($this->widgetArgs['options']) && in_array( $tag, ['checkbox', 'radio'] ) ) {
35
+            $args['checked'] = in_array( $args['value'], (array)$this->widgetArgs[$args['name']] );
36 36
         }
37
-        $args['id'] = $this->get_field_id($args['name']);
38
-        $args['name'] = $this->get_field_name($args['name']);
37
+        $args['id'] = $this->get_field_id( $args['name'] );
38
+        $args['name'] = $this->get_field_name( $args['name'] );
39 39
         $args['is_widget'] = true;
40 40
         return $args;
41 41
     }
@@ -44,13 +44,13 @@  discard block
 block discarded – undo
44 44
      * @param string $tag
45 45
      * @return void
46 46
      */
47
-    protected function renderField($tag, array $args = [])
47
+    protected function renderField( $tag, array $args = [] )
48 48
     {
49
-        $args = $this->normalizeFieldAttributes($tag, $args);
50
-        $field = glsr(Builder::class)->$tag($args['name'], $args);
51
-        echo glsr(Builder::class)->div($field, [
49
+        $args = $this->normalizeFieldAttributes( $tag, $args );
50
+        $field = glsr( Builder::class )->$tag( $args['name'], $args );
51
+        echo glsr( Builder::class )->div( $field, [
52 52
             'class' => 'glsr-field',
53
-        ]);
53
+        ] );
54 54
     }
55 55
 
56 56
     /**
Please login to merge, or discard this patch.
plugin/Contracts/ShortcodeContract.php 2 patches
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -4,15 +4,15 @@
 block discarded – undo
4 4
 
5 5
 interface ShortcodeContract
6 6
 {
7
-    /**
8
-     * @params string|array $atts
9
-     * @return string
10
-     */
11
-    public function buildBlock($atts = []);
7
+	/**
8
+	 * @params string|array $atts
9
+	 * @return string
10
+	 */
11
+	public function buildBlock($atts = []);
12 12
 
13
-    /**
14
-     * @param string|array $atts
15
-     * @return string
16
-     */
17
-    public function buildShortcode($atts = []);
13
+	/**
14
+	 * @param string|array $atts
15
+	 * @return string
16
+	 */
17
+	public function buildShortcode($atts = []);
18 18
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -8,11 +8,11 @@
 block discarded – undo
8 8
      * @params string|array $atts
9 9
      * @return string
10 10
      */
11
-    public function buildBlock($atts = []);
11
+    public function buildBlock( $atts = [] );
12 12
 
13 13
     /**
14 14
      * @param string|array $atts
15 15
      * @return string
16 16
      */
17
-    public function buildShortcode($atts = []);
17
+    public function buildShortcode( $atts = [] );
18 18
 }
Please login to merge, or discard this patch.