Passed
Branch master (2fcc75)
by Paul
11:46
created
plugin/Helpers/Str.php 1 patch
Spacing   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -9,21 +9,21 @@  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
     /**
20 20
      * @param string $string
21 21
      * @return string
22 22
      */
23
-    public static function camelCase($string)
23
+    public static function camelCase( $string )
24 24
     {
25
-        $string = ucwords(str_replace(['-', '_'], ' ', trim($string)));
26
-        return str_replace(' ', '', $string);
25
+        $string = ucwords( str_replace( ['-', '_'], ' ', trim( $string ) ) );
26
+        return str_replace( ' ', '', $string );
27 27
     }
28 28
 
29 29
     /**
@@ -31,9 +31,9 @@  discard block
 block discarded – undo
31 31
      * @param string $needle
32 32
      * @return bool
33 33
      */
34
-    public static function contains($haystack, $needle)
34
+    public static function contains( $haystack, $needle )
35 35
     {
36
-        return false !== strpos($haystack, $needle);
36
+        return false !== strpos( $haystack, $needle );
37 37
     }
38 38
 
39 39
     /**
@@ -42,27 +42,27 @@  discard block
 block discarded – undo
42 42
      * @param string $initialType period|period_space|space
43 43
      * @return string
44 44
      */
45
-    public static function convertName($name, $nameType = '', $initialType = '')
45
+    public static function convertName( $name, $nameType = '', $initialType = '' )
46 46
     {
47
-        $names = preg_split('/\W/u', $name, 0, PREG_SPLIT_NO_EMPTY);
48
-        $firstName = array_shift($names);
49
-        $lastName = array_pop($names);
47
+        $names = preg_split( '/\W/u', $name, 0, PREG_SPLIT_NO_EMPTY );
48
+        $firstName = array_shift( $names );
49
+        $lastName = array_pop( $names );
50 50
         $initialTypes = [
51 51
             'period' => '.',
52 52
             'period_space' => '. ',
53 53
             'space' => ' ',
54 54
         ];
55
-        $initialPunctuation = (string) Arr::get($initialTypes, $initialType, ' ');
56
-        if ('initials' == $nameType) {
57
-            return static::convertToInitials($name, $initialPunctuation);
55
+        $initialPunctuation = (string)Arr::get( $initialTypes, $initialType, ' ' );
56
+        if( 'initials' == $nameType ) {
57
+            return static::convertToInitials( $name, $initialPunctuation );
58 58
         }
59 59
         $nameTypes = [
60 60
             'first' => $firstName,
61
-            'first_initial' => static::convertToInitials($firstName).$initialPunctuation.$lastName,
61
+            'first_initial' => static::convertToInitials( $firstName ).$initialPunctuation.$lastName,
62 62
             'last' => $lastName,
63
-            'last_initial' => $firstName.' '.static::convertToInitials($lastName).$initialPunctuation,
63
+            'last_initial' => $firstName.' '.static::convertToInitials( $lastName ).$initialPunctuation,
64 64
         ];
65
-        return trim((string) Arr::get($nameTypes, $nameType, $name));
65
+        return trim( (string)Arr::get( $nameTypes, $nameType, $name ) );
66 66
     }
67 67
 
68 68
     /**
@@ -70,9 +70,9 @@  discard block
 block discarded – undo
70 70
      * @param string $prefix
71 71
      * @return string
72 72
      */
73
-    public static function convertPathToId($path, $prefix = '')
73
+    public static function convertPathToId( $path, $prefix = '' )
74 74
     {
75
-        return str_replace(['[', ']'], ['-', ''], static::convertPathToName($path, $prefix));
75
+        return str_replace( ['[', ']'], ['-', ''], static::convertPathToName( $path, $prefix ) );
76 76
     }
77 77
 
78 78
     /**
@@ -80,12 +80,12 @@  discard block
 block discarded – undo
80 80
      * @param string $prefix
81 81
      * @return string
82 82
      */
83
-    public static function convertPathToName($path, $prefix = '')
83
+    public static function convertPathToName( $path, $prefix = '' )
84 84
     {
85
-        $levels = explode('.', $path);
86
-        return array_reduce($levels, function ($result, $value) {
85
+        $levels = explode( '.', $path );
86
+        return array_reduce( $levels, function( $result, $value ) {
87 87
             return $result .= '['.$value.']';
88
-        }, $prefix);
88
+        }, $prefix );
89 89
     }
90 90
 
91 91
     /**
@@ -93,12 +93,12 @@  discard block
 block discarded – undo
93 93
      * @param string $initialPunctuation
94 94
      * @return string
95 95
      */
96
-    public static function convertToInitials($name, $initialPunctuation = '')
96
+    public static function convertToInitials( $name, $initialPunctuation = '' )
97 97
     {
98
-        preg_match_all('/(?<=\s|\b)\pL/u', $name, $matches);
99
-        return array_reduce($matches[0], function ($carry, $word) use ($initialPunctuation) {
100
-            $string = extension_loaded('mbstring') ? mb_substr($word, 0, 1) : substr($word, 0, 1);
101
-            return $carry.strtoupper($string).$initialPunctuation;
98
+        preg_match_all( '/(?<=\s|\b)\pL/u', $name, $matches );
99
+        return array_reduce( $matches[0], function( $carry, $word ) use ($initialPunctuation) {
100
+            $string = extension_loaded( 'mbstring' ) ? mb_substr( $word, 0, 1 ) : substr( $word, 0, 1 );
101
+            return $carry.strtoupper( $string ).$initialPunctuation;
102 102
         });
103 103
     }
104 104
 
@@ -106,9 +106,9 @@  discard block
 block discarded – undo
106 106
      * @param string $string
107 107
      * @return string
108 108
      */
109
-    public static function dashCase($string)
109
+    public static function dashCase( $string )
110 110
     {
111
-        return str_replace('_', '-', static::snakeCase($string));
111
+        return str_replace( '_', '-', static::snakeCase( $string ) );
112 112
     }
113 113
 
114 114
     /**
@@ -116,11 +116,11 @@  discard block
 block discarded – undo
116 116
      * @param string $haystack
117 117
      * @return bool
118 118
      */
119
-    public static function endsWith($needle, $haystack)
119
+    public static function endsWith( $needle, $haystack )
120 120
     {
121
-        $length = strlen($needle);
121
+        $length = strlen( $needle );
122 122
         return 0 != $length
123
-            ? substr($haystack, -$length) === $needle
123
+            ? substr( $haystack, -$length ) === $needle
124 124
             : true;
125 125
     }
126 126
 
@@ -130,12 +130,12 @@  discard block
 block discarded – undo
130 130
      * @param string|null $trim
131 131
      * @return string
132 132
      */
133
-    public static function prefix($prefix, $string, $trim = null)
133
+    public static function prefix( $prefix, $string, $trim = null )
134 134
     {
135
-        if (null === $trim) {
135
+        if( null === $trim ) {
136 136
             $trim = $prefix;
137 137
         }
138
-        return $prefix.trim(static::removePrefix($trim, $string));
138
+        return $prefix.trim( static::removePrefix( $trim, $string ) );
139 139
     }
140 140
 
141 141
     /**
@@ -143,10 +143,10 @@  discard block
 block discarded – undo
143 143
      * @param string $string
144 144
      * @return string
145 145
      */
146
-    public static function removePrefix($prefix, $string)
146
+    public static function removePrefix( $prefix, $string )
147 147
     {
148
-        return static::startsWith($prefix, $string)
149
-            ? substr($string, strlen($prefix))
148
+        return static::startsWith( $prefix, $string )
149
+            ? substr( $string, strlen( $prefix ) )
150 150
             : $string;
151 151
     }
152 152
 
@@ -154,16 +154,16 @@  discard block
 block discarded – undo
154 154
      * @param string $string
155 155
      * @return string
156 156
      */
157
-    public static function snakeCase($string)
157
+    public static function snakeCase( $string )
158 158
     {
159
-        if (!ctype_lower($string)) {
160
-            $string = preg_replace('/\s+/u', '', $string);
161
-            $string = preg_replace('/(.)(?=[A-Z])/u', '$1_', $string);
162
-            $string = function_exists('mb_strtolower')
163
-                ? mb_strtolower($string, 'UTF-8')
164
-                : strtolower($string);
159
+        if( !ctype_lower( $string ) ) {
160
+            $string = preg_replace( '/\s+/u', '', $string );
161
+            $string = preg_replace( '/(.)(?=[A-Z])/u', '$1_', $string );
162
+            $string = function_exists( 'mb_strtolower' )
163
+                ? mb_strtolower( $string, 'UTF-8' )
164
+                : strtolower( $string );
165 165
         }
166
-        return str_replace('-', '_', $string);
166
+        return str_replace( '-', '_', $string );
167 167
     }
168 168
 
169 169
     /**
@@ -171,9 +171,9 @@  discard block
 block discarded – undo
171 171
      * @param string $haystack
172 172
      * @return bool
173 173
      */
174
-    public static function startsWith($needle, $haystack)
174
+    public static function startsWith( $needle, $haystack )
175 175
     {
176
-        return substr($haystack, 0, strlen($needle)) === $needle;
176
+        return substr( $haystack, 0, strlen( $needle ) ) === $needle;
177 177
     }
178 178
 
179 179
     /**
@@ -181,10 +181,10 @@  discard block
 block discarded – undo
181 181
      * @param int $length
182 182
      * @return string
183 183
      */
184
-    public static function truncate($string, $length)
184
+    public static function truncate( $string, $length )
185 185
     {
186
-        return strlen($string) > $length
187
-            ? substr($string, 0, $length)
186
+        return strlen( $string ) > $length
187
+            ? substr( $string, 0, $length )
188 188
             : $string;
189 189
     }
190 190
 }
Please login to merge, or discard this patch.
plugin/Controllers/RestReviewController.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
 {
15 15
     public function __construct()
16 16
     {
17
-        $this->meta = new WP_REST_Post_Meta_Fields(Application::POST_TYPE);
17
+        $this->meta = new WP_REST_Post_Meta_Fields( Application::POST_TYPE );
18 18
         $this->namespace = Application::ID.'/v1';
19 19
         $this->post_type = Application::POST_TYPE;
20 20
         $this->rest_base = 'reviews';
@@ -29,13 +29,13 @@  discard block
 block discarded – undo
29 29
         //  ['callback' => [$this, 'createReview'], 'methods' => Server::CREATABLE],
30 30
         //  ['callback' => [$this, 'getReviews'], 'methods' => Server::READABLE],
31 31
         // ]);
32
-        register_rest_route($this->namespace, '/types', [
32
+        register_rest_route( $this->namespace, '/types', [
33 33
             [
34 34
                 'callback' => [$this, 'getReviewTypes'],
35 35
                 'methods' => Server::READABLE,
36 36
                 'permission_callback' => [$this, 'get_items_permissions_check'],
37 37
             ],
38
-        ]);
38
+        ] );
39 39
     }
40 40
 
41 41
     /**
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
     public function createReview()
45 45
     {
46 46
         $response = [];
47
-        return rest_ensure_response($response);
47
+        return rest_ensure_response( $response );
48 48
     }
49 49
 
50 50
     /**
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
     public function getReviews()
54 54
     {
55 55
         $response = [];
56
-        return rest_ensure_response($response);
56
+        return rest_ensure_response( $response );
57 57
     }
58 58
 
59 59
     /**
@@ -62,12 +62,12 @@  discard block
 block discarded – undo
62 62
     public function getReviewTypes()
63 63
     {
64 64
         $response = [];
65
-        foreach (glsr()->reviewTypes as $slug => $name) {
65
+        foreach( glsr()->reviewTypes as $slug => $name ) {
66 66
             $response[] = [
67 67
                 'name' => $name,
68 68
                 'slug' => $slug,
69 69
             ];
70 70
         }
71
-        return rest_ensure_response($response);
71
+        return rest_ensure_response( $response );
72 72
     }
73 73
 }
Please login to merge, or discard this patch.