Passed
Push — feature/rebusify ( 0fe5b2...103190 )
by Paul
08:37 queued 03:55
created
plugin/HelperTraits/Arr.php 1 patch
Spacing   +54 added lines, -54 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 function compareArrays(array $arr1, array $arr2)
10
+    public function compareArrays( 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 function consolidateArray($array)
21
+    public function consolidateArray( $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 function convertDotNotationArray(array $array)
31
+    public function convertDotNotationArray( array $array )
32 32
     {
33 33
         $results = [];
34
-        foreach ($array as $path => $value) {
35
-            $results = $this->dataSet($results, $path, $value);
34
+        foreach( $array as $path => $value ) {
35
+            $results = $this->dataSet( $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 function convertStringToArray($string, $callback = null)
45
+    public function convertStringToArray( $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
     /**
@@ -57,12 +57,12 @@  discard block
 block discarded – undo
57 57
      * @param mixed $fallback
58 58
      * @return mixed
59 59
      */
60
-    public function dataGet($data, $path = '', $fallback = '')
60
+    public function dataGet( $data, $path = '', $fallback = '' )
61 61
     {
62
-        $data = $this->consolidateArray($data);
63
-        $keys = explode('.', $path);
64
-        foreach ($keys as $key) {
65
-            if (!isset($data[$key])) {
62
+        $data = $this->consolidateArray( $data );
63
+        $keys = explode( '.', $path );
64
+        foreach( $keys as $key ) {
65
+            if( !isset($data[$key]) ) {
66 66
                 return $fallback;
67 67
             }
68 68
             $data = $data[$key];
@@ -76,14 +76,14 @@  discard block
 block discarded – undo
76 76
      * @param mixed $value
77 77
      * @return array
78 78
      */
79
-    public function dataSet(array $data, $path, $value)
79
+    public function dataSet( array $data, $path, $value )
80 80
     {
81
-        $token = strtok($path, '.');
81
+        $token = strtok( $path, '.' );
82 82
         $ref = &$data;
83
-        while (false !== $token) {
84
-            $ref = $this->consolidateArray($ref);
83
+        while( false !== $token ) {
84
+            $ref = $this->consolidateArray( $ref );
85 85
             $ref = &$ref[$token];
86
-            $token = strtok('.');
86
+            $token = strtok( '.' );
87 87
         }
88 88
         $ref = $value;
89 89
         return $data;
@@ -94,17 +94,17 @@  discard block
 block discarded – undo
94 94
      * @param string $prefix
95 95
      * @return array
96 96
      */
97
-    public function flattenArray(array $array, $flattenValue = false, $prefix = '')
97
+    public function flattenArray( array $array, $flattenValue = false, $prefix = '' )
98 98
     {
99 99
         $result = [];
100
-        foreach ($array as $key => $value) {
101
-            $newKey = ltrim($prefix.'.'.$key, '.');
102
-            if ($this->isIndexedFlatArray($value)) {
103
-                if ($flattenValue) {
104
-                    $value = '['.implode(', ', $value).']';
100
+        foreach( $array as $key => $value ) {
101
+            $newKey = ltrim( $prefix.'.'.$key, '.' );
102
+            if( $this->isIndexedFlatArray( $value ) ) {
103
+                if( $flattenValue ) {
104
+                    $value = '['.implode( ', ', $value ).']';
105 105
                 }
106
-            } elseif (is_array($value)) {
107
-                $result = array_merge($result, $this->flattenArray($value, $flattenValue, $newKey));
106
+            } elseif( is_array( $value ) ) {
107
+                $result = array_merge( $result, $this->flattenArray( $value, $flattenValue, $newKey ) );
108 108
                 continue;
109 109
             }
110 110
             $result[$newKey] = $value;
@@ -117,47 +117,47 @@  discard block
 block discarded – undo
117 117
      * @param string $position
118 118
      * @return array
119 119
      */
120
-    public function insertInArray(array $array, array $insert, $key, $position = 'before')
120
+    public function insertInArray( array $array, array $insert, $key, $position = 'before' )
121 121
     {
122
-        $keyPosition = intval(array_search($key, array_keys($array)));
123
-        if ('after' == $position) {
122
+        $keyPosition = intval( array_search( $key, array_keys( $array ) ) );
123
+        if( 'after' == $position ) {
124 124
             ++$keyPosition;
125 125
         }
126
-        if (false !== $keyPosition) {
127
-            $result = array_slice($array, 0, $keyPosition);
128
-            $result = array_merge($result, $insert);
129
-            return array_merge($result, array_slice($array, $keyPosition));
126
+        if( false !== $keyPosition ) {
127
+            $result = array_slice( $array, 0, $keyPosition );
128
+            $result = array_merge( $result, $insert );
129
+            return array_merge( $result, array_slice( $array, $keyPosition ) );
130 130
         }
131
-        return array_merge($array, $insert);
131
+        return array_merge( $array, $insert );
132 132
     }
133 133
 
134 134
     /**
135 135
      * @param mixed $array
136 136
      * @return bool
137 137
      */
138
-    public function isIndexedFlatArray($array)
138
+    public function isIndexedFlatArray( $array )
139 139
     {
140
-        if (!is_array($array) || array_filter($array, 'is_array')) {
140
+        if( !is_array( $array ) || array_filter( $array, 'is_array' ) ) {
141 141
             return false;
142 142
         }
143
-        return wp_is_numeric_array($array);
143
+        return wp_is_numeric_array( $array );
144 144
     }
145 145
 
146 146
     /**
147 147
      * @param bool $prefixed
148 148
      * @return array
149 149
      */
150
-    public function prefixArrayKeys(array $values, $prefixed = true)
150
+    public function prefixArrayKeys( array $values, $prefixed = true )
151 151
     {
152 152
         $trim = '_';
153 153
         $prefix = $prefixed
154 154
             ? $trim
155 155
             : '';
156 156
         $prefixed = [];
157
-        foreach ($values as $key => $value) {
158
-            $key = trim($key);
159
-            if (0 === strpos($key, $trim)) {
160
-                $key = substr($key, strlen($trim));
157
+        foreach( $values as $key => $value ) {
158
+            $key = trim( $key );
159
+            if( 0 === strpos( $key, $trim ) ) {
160
+                $key = substr( $key, strlen( $trim ) );
161 161
             }
162 162
             $prefixed[$prefix.$key] = $value;
163 163
         }
@@ -167,15 +167,15 @@  discard block
 block discarded – undo
167 167
     /**
168 168
      * @return array
169 169
      */
170
-    public function removeEmptyArrayValues(array $array)
170
+    public function removeEmptyArrayValues( array $array )
171 171
     {
172 172
         $result = [];
173
-        foreach ($array as $key => $value) {
174
-            if (!$value) {
173
+        foreach( $array as $key => $value ) {
174
+            if( !$value ) {
175 175
                 continue;
176 176
             }
177
-            $result[$key] = is_array($value)
178
-                ? $this->removeEmptyArrayValues($value)
177
+            $result[$key] = is_array( $value )
178
+                ? $this->removeEmptyArrayValues( $value )
179 179
                 : $value;
180 180
         }
181 181
         return $result;
@@ -184,8 +184,8 @@  discard block
 block discarded – undo
184 184
     /**
185 185
      * @return array
186 186
      */
187
-    public function unprefixArrayKeys(array $values)
187
+    public function unprefixArrayKeys( array $values )
188 188
     {
189
-        return $this->prefixArrayKeys($values, false);
189
+        return $this->prefixArrayKeys( $values, false );
190 190
     }
191 191
 }
Please login to merge, or discard this patch.
plugin/HelperTraits/Str.php 1 patch
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -8,40 +8,40 @@  discard block
 block discarded – undo
8 8
      * @param string $string
9 9
      * @return string
10 10
      */
11
-    public function camelCase($string)
11
+    public function camelCase( $string )
12 12
     {
13
-        $string = ucwords(str_replace(['-', '_'], ' ', trim($string)));
14
-        return str_replace(' ', '', $string);
13
+        $string = ucwords( str_replace( ['-', '_'], ' ', trim( $string ) ) );
14
+        return str_replace( ' ', '', $string );
15 15
     }
16 16
 
17 17
     /**
18 18
      * @param string $name
19 19
      * @return string
20 20
      */
21
-    public function convertPathToId($path, $prefix = '')
21
+    public function convertPathToId( $path, $prefix = '' )
22 22
     {
23
-        return str_replace(['[', ']'], ['-', ''], $this->convertPathToName($path, $prefix));
23
+        return str_replace( ['[', ']'], ['-', ''], $this->convertPathToName( $path, $prefix ) );
24 24
     }
25 25
 
26 26
     /**
27 27
      * @param string $path
28 28
      * @return string
29 29
      */
30
-    public function convertPathToName($path, $prefix = '')
30
+    public function convertPathToName( $path, $prefix = '' )
31 31
     {
32
-        $levels = explode('.', $path);
33
-        return array_reduce($levels, function ($result, $value) {
32
+        $levels = explode( '.', $path );
33
+        return array_reduce( $levels, function( $result, $value ) {
34 34
             return $result .= '['.$value.']';
35
-        }, $prefix);
35
+        }, $prefix );
36 36
     }
37 37
 
38 38
     /**
39 39
      * @param string $string
40 40
      * @return string
41 41
      */
42
-    public function dashCase($string)
42
+    public function dashCase( $string )
43 43
     {
44
-        return str_replace('_', '-', $this->snakeCase($string));
44
+        return str_replace( '_', '-', $this->snakeCase( $string ) );
45 45
     }
46 46
 
47 47
     /**
@@ -49,11 +49,11 @@  discard block
 block discarded – undo
49 49
      * @param string $haystack
50 50
      * @return bool
51 51
      */
52
-    public function endsWith($needle, $haystack)
52
+    public function endsWith( $needle, $haystack )
53 53
     {
54
-        $length = strlen($needle);
54
+        $length = strlen( $needle );
55 55
         return 0 != $length
56
-            ? substr($haystack, -$length) === $needle
56
+            ? substr( $haystack, -$length ) === $needle
57 57
             : true;
58 58
     }
59 59
 
@@ -63,12 +63,12 @@  discard block
 block discarded – undo
63 63
      * @param string|null $trim
64 64
      * @return string
65 65
      */
66
-    public function prefix($prefix, $string, $trim = null)
66
+    public function prefix( $prefix, $string, $trim = null )
67 67
     {
68
-        if (null === $trim) {
68
+        if( null === $trim ) {
69 69
             $trim = $prefix;
70 70
         }
71
-        return $prefix.trim($this->removePrefix($trim, $string));
71
+        return $prefix.trim( $this->removePrefix( $trim, $string ) );
72 72
     }
73 73
 
74 74
     /**
@@ -76,10 +76,10 @@  discard block
 block discarded – undo
76 76
      * @param string $string
77 77
      * @return string
78 78
      */
79
-    public function removePrefix($prefix, $string)
79
+    public function removePrefix( $prefix, $string )
80 80
     {
81
-        return $this->startsWith($prefix, $string)
82
-            ? substr($string, strlen($prefix))
81
+        return $this->startsWith( $prefix, $string )
82
+            ? substr( $string, strlen( $prefix ) )
83 83
             : $string;
84 84
     }
85 85
 
@@ -87,16 +87,16 @@  discard block
 block discarded – undo
87 87
      * @param string $string
88 88
      * @return string
89 89
      */
90
-    public function snakeCase($string)
90
+    public function snakeCase( $string )
91 91
     {
92
-        if (!ctype_lower($string)) {
93
-            $string = preg_replace('/\s+/u', '', $string);
94
-            $string = preg_replace('/(.)(?=[A-Z])/u', '$1_', $string);
95
-            $string = function_exists('mb_strtolower')
96
-                ? mb_strtolower($string, 'UTF-8')
97
-                : strtolower($string);
92
+        if( !ctype_lower( $string ) ) {
93
+            $string = preg_replace( '/\s+/u', '', $string );
94
+            $string = preg_replace( '/(.)(?=[A-Z])/u', '$1_', $string );
95
+            $string = function_exists( 'mb_strtolower' )
96
+                ? mb_strtolower( $string, 'UTF-8' )
97
+                : strtolower( $string );
98 98
         }
99
-        return str_replace('-', '_', $string);
99
+        return str_replace( '-', '_', $string );
100 100
     }
101 101
 
102 102
     /**
@@ -104,8 +104,8 @@  discard block
 block discarded – undo
104 104
      * @param string $haystack
105 105
      * @return bool
106 106
      */
107
-    public function startsWith($needle, $haystack)
107
+    public function startsWith( $needle, $haystack )
108 108
     {
109
-        return substr($haystack, 0, strlen($needle)) === $needle;
109
+        return substr( $haystack, 0, strlen( $needle ) ) === $needle;
110 110
     }
111 111
 }
Please login to merge, or discard this patch.
plugin/Controllers/SettingsController.php 1 patch
Spacing   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -14,16 +14,16 @@  discard block
 block discarded – undo
14 14
      * @return array
15 15
      * @callback register_setting
16 16
      */
17
-    public function callbackRegisterSettings($input)
17
+    public function callbackRegisterSettings( $input )
18 18
     {
19
-        $settings = glsr(Helper::class)->consolidateArray($input);
20
-        if (1 === count($settings) && array_key_exists('settings', $settings)) {
21
-            $options = array_replace_recursive(glsr(OptionManager::class)->all(), $input);
22
-            $options = $this->sanitizeGeneral($input, $options);
23
-            $options = $this->sanitizeSubmissions($input, $options);
24
-            $options = $this->sanitizeTranslations($input, $options);
25
-            if (filter_input(INPUT_POST, 'option_page') == Application::ID.'-settings') {
26
-                glsr(Notice::class)->addSuccess(__('Settings updated.', 'site-reviews'));
19
+        $settings = glsr( Helper::class )->consolidateArray( $input );
20
+        if( 1 === count( $settings ) && array_key_exists( 'settings', $settings ) ) {
21
+            $options = array_replace_recursive( glsr( OptionManager::class )->all(), $input );
22
+            $options = $this->sanitizeGeneral( $input, $options );
23
+            $options = $this->sanitizeSubmissions( $input, $options );
24
+            $options = $this->sanitizeTranslations( $input, $options );
25
+            if( filter_input( INPUT_POST, 'option_page' ) == Application::ID.'-settings' ) {
26
+                glsr( Notice::class )->addSuccess( __( 'Settings updated.', 'site-reviews' ) );
27 27
             }
28 28
             return $options;
29 29
         }
@@ -36,31 +36,31 @@  discard block
 block discarded – undo
36 36
      */
37 37
     public function registerSettings()
38 38
     {
39
-        register_setting(Application::ID.'-settings', OptionManager::databaseKey(), [
39
+        register_setting( Application::ID.'-settings', OptionManager::databaseKey(), [
40 40
             'sanitize_callback' => [$this, 'callbackRegisterSettings'],
41
-        ]);
41
+        ] );
42 42
     }
43 43
 
44 44
     /**
45 45
      * @return array
46 46
      */
47
-    protected function sanitizeGeneral(array $input, array $options)
47
+    protected function sanitizeGeneral( array $input, array $options )
48 48
     {
49 49
         $inputForm = $input['settings']['general'];
50
-        if (!$this->hasMultilingualIntegration($inputForm['support']['multilingual'])) {
50
+        if( !$this->hasMultilingualIntegration( $inputForm['support']['multilingual'] ) ) {
51 51
             $options['settings']['general']['support']['multilingual'] = '';
52 52
         }
53
-        if ('' == trim($inputForm['notification_message'])) {
53
+        if( '' == trim( $inputForm['notification_message'] ) ) {
54 54
             $options['settings']['general']['notification_message'] = glsr()->defaults['settings']['general']['notification_message'];
55 55
         }
56
-        $options['settings']['general']['notifications'] = glsr_get($inputForm, 'notifications', []);
56
+        $options['settings']['general']['notifications'] = glsr_get( $inputForm, 'notifications', [] );
57 57
         return $options;
58 58
     }
59 59
 
60 60
     /**
61 61
      * @return array
62 62
      */
63
-    protected function sanitizeSubmissions(array $input, array $options)
63
+    protected function sanitizeSubmissions( array $input, array $options )
64 64
     {
65 65
         $inputForm = $input['settings']['submissions'];
66 66
         $options['settings']['submissions']['required'] = isset($inputForm['required'])
@@ -72,20 +72,20 @@  discard block
 block discarded – undo
72 72
     /**
73 73
      * @return array
74 74
      */
75
-    protected function sanitizeTranslations(array $input, array $options)
75
+    protected function sanitizeTranslations( array $input, array $options )
76 76
     {
77
-        if (isset($input['settings']['strings'])) {
78
-            $options['settings']['strings'] = array_values(array_filter($input['settings']['strings']));
77
+        if( isset($input['settings']['strings']) ) {
78
+            $options['settings']['strings'] = array_values( array_filter( $input['settings']['strings'] ) );
79 79
             $allowedTags = [
80 80
                 'a' => ['class' => [], 'href' => [], 'target' => []],
81 81
                 'span' => ['class' => []],
82 82
             ];
83
-            array_walk($options['settings']['strings'], function (&$string) use ($allowedTags) {
84
-                if (isset($string['s2'])) {
85
-                    $string['s2'] = wp_kses($string['s2'], $allowedTags);
83
+            array_walk( $options['settings']['strings'], function( &$string ) use ($allowedTags) {
84
+                if( isset($string['s2']) ) {
85
+                    $string['s2'] = wp_kses( $string['s2'], $allowedTags );
86 86
                 }
87
-                if (isset($string['p2'])) {
88
-                    $string['p2'] = wp_kses($string['p2'], $allowedTags);
87
+                if( isset($string['p2']) ) {
88
+                    $string['p2'] = wp_kses( $string['p2'], $allowedTags );
89 89
                 }
90 90
             });
91 91
         }
@@ -95,24 +95,24 @@  discard block
 block discarded – undo
95 95
     /**
96 96
      * @return bool
97 97
      */
98
-    protected function hasMultilingualIntegration($integration)
98
+    protected function hasMultilingualIntegration( $integration )
99 99
     {
100
-        if (!in_array($integration, ['polylang', 'wpml'])) {
100
+        if( !in_array( $integration, ['polylang', 'wpml'] ) ) {
101 101
             return false;
102 102
         }
103
-        $integrationClass = 'GeminiLabs\SiteReviews\Modules\\'.ucfirst($integration);
104
-        if (!glsr($integrationClass)->isActive()) {
105
-            glsr(Notice::class)->addError(sprintf(
106
-                __('Please install/activate the %s plugin to enable integration.', 'site-reviews'),
107
-                constant($integrationClass.'::PLUGIN_NAME')
108
-            ));
103
+        $integrationClass = 'GeminiLabs\SiteReviews\Modules\\'.ucfirst( $integration );
104
+        if( !glsr( $integrationClass )->isActive() ) {
105
+            glsr( Notice::class )->addError( sprintf(
106
+                __( 'Please install/activate the %s plugin to enable integration.', 'site-reviews' ),
107
+                constant( $integrationClass.'::PLUGIN_NAME' )
108
+            ) );
109 109
             return false;
110
-        } elseif (!glsr($integrationClass)->isSupported()) {
111
-            glsr(Notice::class)->addError(sprintf(
112
-                __('Please update the %s plugin to v%s or greater to enable integration.', 'site-reviews'),
113
-                constant($integrationClass.'::PLUGIN_NAME'),
114
-                constant($integrationClass.'::SUPPORTED_VERSION')
115
-            ));
110
+        } elseif( !glsr( $integrationClass )->isSupported() ) {
111
+            glsr( Notice::class )->addError( sprintf(
112
+                __( 'Please update the %s plugin to v%s or greater to enable integration.', 'site-reviews' ),
113
+                constant( $integrationClass.'::PLUGIN_NAME' ),
114
+                constant( $integrationClass.'::SUPPORTED_VERSION' )
115
+            ) );
116 116
             return false;
117 117
         }
118 118
         return true;
Please login to merge, or discard this patch.
plugin/Database/OptionManager.php 1 patch
Spacing   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -15,14 +15,14 @@  discard block
 block discarded – undo
15 15
     /**
16 16
      * @return string
17 17
      */
18
-    public static function databaseKey($version = null)
18
+    public static function databaseKey( $version = null )
19 19
     {
20
-        if (null === $version) {
21
-            $version = explode('.', glsr()->version);
22
-            $version = array_shift($version);
20
+        if( null === $version ) {
21
+            $version = explode( '.', glsr()->version );
22
+            $version = array_shift( $version );
23 23
         }
24
-        return glsr(Helper::class)->snakeCase(
25
-            Application::ID.'-v'.intval($version)
24
+        return glsr( Helper::class )->snakeCase(
25
+            Application::ID.'-v'.intval( $version )
26 26
         );
27 27
     }
28 28
 
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
      */
32 32
     public function all()
33 33
     {
34
-        if (empty($this->options)) {
34
+        if( empty($this->options) ) {
35 35
             $this->reset();
36 36
         }
37 37
         return $this->options;
@@ -41,20 +41,20 @@  discard block
 block discarded – undo
41 41
      * @param string $path
42 42
      * @return bool
43 43
      */
44
-    public function delete($path)
44
+    public function delete( $path )
45 45
     {
46
-        $keys = explode('.', $path);
47
-        $last = array_pop($keys);
46
+        $keys = explode( '.', $path );
47
+        $last = array_pop( $keys );
48 48
         $options = $this->all();
49 49
         $pointer = &$options;
50
-        foreach ($keys as $key) {
51
-            if (!isset($pointer[$key]) || !is_array($pointer[$key])) {
50
+        foreach( $keys as $key ) {
51
+            if( !isset($pointer[$key]) || !is_array( $pointer[$key] ) ) {
52 52
                 continue;
53 53
             }
54 54
             $pointer = &$pointer[$key];
55 55
         }
56 56
         unset($pointer[$last]);
57
-        return $this->set($options);
57
+        return $this->set( $options );
58 58
     }
59 59
 
60 60
     /**
@@ -63,19 +63,19 @@  discard block
 block discarded – undo
63 63
      * @param string $cast
64 64
      * @return mixed
65 65
      */
66
-    public function get($path = '', $fallback = '', $cast = '')
66
+    public function get( $path = '', $fallback = '', $cast = '' )
67 67
     {
68
-        $result = glsr(Helper::class)->dataGet($this->all(), $path, $fallback);
69
-        return glsr(Helper::class)->castTo($cast, $result);
68
+        $result = glsr( Helper::class )->dataGet( $this->all(), $path, $fallback );
69
+        return glsr( Helper::class )->castTo( $cast, $result );
70 70
     }
71 71
 
72 72
     /**
73 73
      * @param string $path
74 74
      * @return bool
75 75
      */
76
-    public function getBool($path)
76
+    public function getBool( $path )
77 77
     {
78
-        return 'yes' == $this->get($path)
78
+        return 'yes' == $this->get( $path )
79 79
             ? true
80 80
             : false;
81 81
     }
@@ -86,13 +86,13 @@  discard block
 block discarded – undo
86 86
      * @param string $cast
87 87
      * @return mixed
88 88
      */
89
-    public function getWP($path, $fallback = '', $cast = '')
89
+    public function getWP( $path, $fallback = '', $cast = '' )
90 90
     {
91
-        $option = get_option($path, $fallback);
92
-        if (empty($option)) {
91
+        $option = get_option( $path, $fallback );
92
+        if( empty($option) ) {
93 93
             $option = $fallback;
94 94
         }
95
-        return glsr(Helper::class)->castTo($cast, $option);
95
+        return glsr( Helper::class )->castTo( $cast, $option );
96 96
     }
97 97
 
98 98
     /**
@@ -100,25 +100,25 @@  discard block
 block discarded – undo
100 100
      */
101 101
     public function json()
102 102
     {
103
-        return json_encode($this->all());
103
+        return json_encode( $this->all() );
104 104
     }
105 105
 
106 106
     /**
107 107
      * @return array
108 108
      */
109
-    public function normalize(array $options = [])
109
+    public function normalize( array $options = [] )
110 110
     {
111 111
         $options = wp_parse_args(
112
-            glsr(Helper::class)->flattenArray($options),
113
-            glsr(DefaultsManager::class)->defaults()
112
+            glsr( Helper::class )->flattenArray( $options ),
113
+            glsr( DefaultsManager::class )->defaults()
114 114
         );
115
-        array_walk($options, function (&$value) {
116
-            if (!is_string($value)) {
115
+        array_walk( $options, function( &$value ) {
116
+            if( !is_string( $value ) ) {
117 117
                 return;
118 118
             }
119
-            $value = wp_kses($value, wp_kses_allowed_html('post'));
119
+            $value = wp_kses( $value, wp_kses_allowed_html( 'post' ) );
120 120
         });
121
-        return glsr(Helper::class)->convertDotNotationArray($options);
121
+        return glsr( Helper::class )->convertDotNotationArray( $options );
122 122
     }
123 123
 
124 124
     /**
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
      */
127 127
     public function isRecaptchaEnabled()
128 128
     {
129
-        $integration = $this->get('settings.submissions.recaptcha.integration');
129
+        $integration = $this->get( 'settings.submissions.recaptcha.integration' );
130 130
         return 'all' == $integration || ('guest' == $integration && !is_user_logged_in());
131 131
     }
132 132
 
@@ -135,9 +135,9 @@  discard block
 block discarded – undo
135 135
      */
136 136
     public function reset()
137 137
     {
138
-        $options = $this->getWP(static::databaseKey(), []);
139
-        if (!is_array($options) || empty($options)) {
140
-            delete_option(static::databaseKey());
138
+        $options = $this->getWP( static::databaseKey(), [] );
139
+        if( !is_array( $options ) || empty($options) ) {
140
+            delete_option( static::databaseKey() );
141 141
             $options = glsr()->defaults;
142 142
         }
143 143
         $this->options = $options;
@@ -148,12 +148,12 @@  discard block
 block discarded – undo
148 148
      * @param mixed $value
149 149
      * @return bool
150 150
      */
151
-    public function set($pathOrOptions, $value = '')
151
+    public function set( $pathOrOptions, $value = '' )
152 152
     {
153
-        if (is_string($pathOrOptions)) {
154
-            $pathOrOptions = glsr(Helper::class)->dataSet($this->all(), $pathOrOptions, $value);
153
+        if( is_string( $pathOrOptions ) ) {
154
+            $pathOrOptions = glsr( Helper::class )->dataSet( $this->all(), $pathOrOptions, $value );
155 155
         }
156
-        if ($result = update_option(static::databaseKey(), (array) $pathOrOptions)) {
156
+        if( $result = update_option( static::databaseKey(), (array)$pathOrOptions ) ) {
157 157
             $this->reset();
158 158
         }
159 159
         return $result;
Please login to merge, or discard this patch.
plugin/Database/SqlQueries.php 1 patch
Spacing   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -21,17 +21,17 @@  discard block
 block discarded – undo
21 21
      * @param string $metaReviewId
22 22
      * @return int
23 23
      */
24
-    public function getPostIdFromReviewId($metaReviewId)
24
+    public function getPostIdFromReviewId( $metaReviewId )
25 25
     {
26
-        $postId = $this->db->get_var("
26
+        $postId = $this->db->get_var( "
27 27
             SELECT p.ID
28 28
             FROM {$this->db->posts} AS p
29 29
             INNER JOIN {$this->db->postmeta} AS m ON p.ID = m.post_id
30 30
             WHERE p.post_type = '{$this->postType}'
31 31
             AND m.meta_key = '_review_id'
32 32
             AND m.meta_value = '{$metaReviewId}'
33
-        ");
34
-        return intval($postId);
33
+        " );
34
+        return intval( $postId );
35 35
     }
36 36
 
37 37
     /**
@@ -39,23 +39,23 @@  discard block
 block discarded – undo
39 39
      * @param int $limit
40 40
      * @return array
41 41
      */
42
-    public function getReviewCounts(array $args, $lastPostId = 0, $limit = 500)
42
+    public function getReviewCounts( array $args, $lastPostId = 0, $limit = 500 )
43 43
     {
44
-        return (array) $this->db->get_results("
44
+        return (array)$this->db->get_results( "
45 45
             SELECT DISTINCT p.ID, m1.meta_value AS rating, m2.meta_value AS type
46 46
             FROM {$this->db->posts} AS p
47 47
             INNER JOIN {$this->db->postmeta} AS m1 ON p.ID = m1.post_id
48 48
             INNER JOIN {$this->db->postmeta} AS m2 ON p.ID = m2.post_id
49
-            {$this->getInnerJoinForCounts($args)}
49
+            {$this->getInnerJoinForCounts( $args )}
50 50
             WHERE p.ID > {$lastPostId}
51 51
             AND p.post_status = 'publish'
52 52
             AND p.post_type = '{$this->postType}'
53 53
             AND m1.meta_key = '_rating'
54 54
             AND m2.meta_key = '_review_type'
55
-            {$this->getAndForCounts($args)}
55
+            {$this->getAndForCounts( $args )}
56 56
             ORDER By p.ID ASC
57 57
             LIMIT {$limit}
58
-        ");
58
+        " );
59 59
     }
60 60
 
61 61
     /**
@@ -63,17 +63,17 @@  discard block
 block discarded – undo
63 63
      * @param string $metaKey
64 64
      * @return array
65 65
      */
66
-    public function getReviewCountsFor($metaKey)
66
+    public function getReviewCountsFor( $metaKey )
67 67
     {
68
-        $metaKey = glsr(Helper::class)->prefix('_', $metaKey);
69
-        return (array) $this->db->get_results("
68
+        $metaKey = glsr( Helper::class )->prefix( '_', $metaKey );
69
+        return (array)$this->db->get_results( "
70 70
             SELECT DISTINCT m.meta_value AS name, COUNT(*) num_posts
71 71
             FROM {$this->db->posts} AS p
72 72
             INNER JOIN {$this->db->postmeta} AS m ON p.ID = m.post_id
73 73
             WHERE p.post_type = '{$this->postType}'
74 74
             AND m.meta_key = '{$metaKey}'
75 75
             GROUP BY name
76
-        ");
76
+        " );
77 77
     }
78 78
 
79 79
     /**
@@ -81,9 +81,9 @@  discard block
 block discarded – undo
81 81
      * @param string $reviewType
82 82
      * @return array
83 83
      */
84
-    public function getReviewIdsByType($reviewType)
84
+    public function getReviewIdsByType( $reviewType )
85 85
     {
86
-        $results = $this->db->get_col("
86
+        $results = $this->db->get_col( "
87 87
             SELECT DISTINCT m1.meta_value AS review_id
88 88
             FROM {$this->db->posts} AS p
89 89
             INNER JOIN {$this->db->postmeta} AS m1 ON p.ID = m1.post_id
@@ -92,8 +92,8 @@  discard block
 block discarded – undo
92 92
             AND m1.meta_key = '_review_id'
93 93
             AND m2.meta_key = '_review_type'
94 94
             AND m2.meta_value = '{$reviewType}'
95
-        ");
96
-        return array_keys(array_flip($results));
95
+        " );
96
+        return array_keys( array_flip( $results ) );
97 97
     }
98 98
 
99 99
     /**
@@ -101,12 +101,12 @@  discard block
 block discarded – undo
101 101
      * @param int $limit
102 102
      * @return array
103 103
      */
104
-    public function getReviewRatingsFromIds(array $postIds, $greaterThanId = 0, $limit = 100)
104
+    public function getReviewRatingsFromIds( array $postIds, $greaterThanId = 0, $limit = 100 )
105 105
     {
106
-        sort($postIds);
107
-        $postIds = array_slice($postIds, intval(array_search($greaterThanId, $postIds)), $limit);
108
-        $postIds = implode(',', $postIds);
109
-        return (array) $this->db->get_results("
106
+        sort( $postIds );
107
+        $postIds = array_slice( $postIds, intval( array_search( $greaterThanId, $postIds ) ), $limit );
108
+        $postIds = implode( ',', $postIds );
109
+        return (array)$this->db->get_results( "
110 110
             SELECT p.ID, m.meta_value AS rating
111 111
             FROM {$this->db->posts} AS p
112 112
             INNER JOIN {$this->db->postmeta} AS m ON p.ID = m.post_id
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
             GROUP BY p.ID
119 119
             ORDER By p.ID ASC
120 120
             LIMIT {$limit}
121
-        ");
121
+        " );
122 122
     }
123 123
 
124 124
     /**
@@ -126,10 +126,10 @@  discard block
 block discarded – undo
126 126
      * @param string $status
127 127
      * @return array
128 128
      */
129
-    public function getReviewsMeta($key, $status = 'publish')
129
+    public function getReviewsMeta( $key, $status = 'publish' )
130 130
     {
131
-        $key = glsr(Helper::class)->prefix('_', $key);
132
-        $values = $this->db->get_col("
131
+        $key = glsr( Helper::class )->prefix( '_', $key );
132
+        $values = $this->db->get_col( "
133 133
             SELECT DISTINCT m.meta_value
134 134
             FROM {$this->db->postmeta} m
135 135
             LEFT JOIN {$this->db->posts} p ON p.ID = m.post_id
@@ -139,8 +139,8 @@  discard block
 block discarded – undo
139 139
             AND p.post_status = '{$status}'
140 140
             GROUP BY p.ID -- remove duplicate meta_value entries
141 141
             ORDER BY m.meta_id ASC -- sort by oldest meta_value
142
-        ");
143
-        sort($values);
142
+        " );
143
+        sort( $values );
144 144
         return $values;
145 145
     }
146 146
 
@@ -148,34 +148,34 @@  discard block
 block discarded – undo
148 148
      * @param string $and
149 149
      * @return string
150 150
      */
151
-    protected function getAndForCounts(array $args, $and = '')
151
+    protected function getAndForCounts( array $args, $and = '' )
152 152
     {
153
-        $postIds = implode(',', array_filter(glsr_get($args, 'post_ids', [])));
154
-        $termIds = implode(',', array_filter(glsr_get($args, 'term_ids', [])));
155
-        if (!empty($args['type'])) {
156
-            $and.= "AND m2.meta_value = '{$args['type']}' ";
153
+        $postIds = implode( ',', array_filter( glsr_get( $args, 'post_ids', [] ) ) );
154
+        $termIds = implode( ',', array_filter( glsr_get( $args, 'term_ids', [] ) ) );
155
+        if( !empty($args['type']) ) {
156
+            $and .= "AND m2.meta_value = '{$args['type']}' ";
157 157
         }
158
-        if ($postIds) {
159
-            $and.= "AND m3.meta_key = '_assigned_to' AND m3.meta_value IN ({$postIds}) ";
158
+        if( $postIds ) {
159
+            $and .= "AND m3.meta_key = '_assigned_to' AND m3.meta_value IN ({$postIds}) ";
160 160
         }
161
-        if ($termIds) {
162
-            $and.= "AND tr.term_taxonomy_id IN ({$termIds}) ";
161
+        if( $termIds ) {
162
+            $and .= "AND tr.term_taxonomy_id IN ({$termIds}) ";
163 163
         }
164
-        return apply_filters('site-reviews/query/and-for-counts', $and);
164
+        return apply_filters( 'site-reviews/query/and-for-counts', $and );
165 165
     }
166 166
 
167 167
     /**
168 168
      * @param string $innerJoin
169 169
      * @return string
170 170
      */
171
-    protected function getInnerJoinForCounts(array $args, $innerJoin = '')
171
+    protected function getInnerJoinForCounts( array $args, $innerJoin = '' )
172 172
     {
173
-        if (!empty(glsr_get($args, 'post_ids'))) {
174
-            $innerJoin.= "INNER JOIN {$this->db->postmeta} AS m3 ON p.ID = m3.post_id ";
173
+        if( !empty(glsr_get( $args, 'post_ids' )) ) {
174
+            $innerJoin .= "INNER JOIN {$this->db->postmeta} AS m3 ON p.ID = m3.post_id ";
175 175
         }
176
-        if (!empty(glsr_get($args, 'term_ids'))) {
177
-            $innerJoin.= "INNER JOIN {$this->db->term_relationships} AS tr ON p.ID = tr.object_id ";
176
+        if( !empty(glsr_get( $args, 'term_ids' )) ) {
177
+            $innerJoin .= "INNER JOIN {$this->db->term_relationships} AS tr ON p.ID = tr.object_id ";
178 178
         }
179
-        return apply_filters('site-reviews/query/inner-join-for-counts', $innerJoin);
179
+        return apply_filters( 'site-reviews/query/inner-join-for-counts', $innerJoin );
180 180
     }
181 181
 }
Please login to merge, or discard this patch.
plugin/Modules/Upgrader.php 1 patch
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -18,24 +18,24 @@  discard block
 block discarded – undo
18 18
     public function run()
19 19
     {
20 20
         $filenames = [];
21
-        $iterator = new DirectoryIterator(dirname(__FILE__).'/Upgrader');
22
-        foreach ($iterator as $fileinfo) {
23
-            if ($fileinfo->isFile()) {
21
+        $iterator = new DirectoryIterator( dirname( __FILE__ ).'/Upgrader' );
22
+        foreach( $iterator as $fileinfo ) {
23
+            if( $fileinfo->isFile() ) {
24 24
                 $filenames[] = $fileinfo->getFilename();
25 25
             }
26 26
         }
27
-        natsort($filenames);
27
+        natsort( $filenames );
28 28
         $this->currentVersion = $this->currentVersion();
29
-        array_walk($filenames, function ($file) {
30
-            $className = str_replace('.php', '', $file);
31
-            $upgradeFromVersion = str_replace(['Upgrade_', '_'], ['', '.'], $className);
32
-            $suffix = preg_replace('/[\d.]+(.+)?/', '${1}', glsr()->version); // allow alpha/beta versions
33
-            if ('0.0.0' == $this->currentVersion
34
-                || version_compare($this->currentVersion, $upgradeFromVersion.$suffix, '>=')) {
29
+        array_walk( $filenames, function( $file ) {
30
+            $className = str_replace( '.php', '', $file );
31
+            $upgradeFromVersion = str_replace( ['Upgrade_', '_'], ['', '.'], $className );
32
+            $suffix = preg_replace( '/[\d.]+(.+)?/', '${1}', glsr()->version ); // allow alpha/beta versions
33
+            if( '0.0.0' == $this->currentVersion
34
+                || version_compare( $this->currentVersion, $upgradeFromVersion.$suffix, '>=' ) ) {
35 35
                 return;
36 36
             }
37
-            glsr('Modules\\Upgrader\\'.$className);
38
-            glsr_log()->notice('Completed Upgrade for v'.$upgradeFromVersion.$suffix);
37
+            glsr( 'Modules\\Upgrader\\'.$className );
38
+            glsr_log()->notice( 'Completed Upgrade for v'.$upgradeFromVersion.$suffix );
39 39
         });
40 40
         $this->finish();
41 41
     }
@@ -45,10 +45,10 @@  discard block
 block discarded – undo
45 45
      */
46 46
     public function finish()
47 47
     {
48
-        if ($this->currentVersion !== glsr()->version) {
48
+        if( $this->currentVersion !== glsr()->version ) {
49 49
             $this->setReviewCounts();
50
-            $this->updateVersionFrom($this->currentVersion);
51
-        } elseif (!glsr(OptionManager::class)->get('last_review_count', false)) {
50
+            $this->updateVersionFrom( $this->currentVersion );
51
+        } elseif( !glsr( OptionManager::class )->get( 'last_review_count', false ) ) {
52 52
             $this->setReviewCounts();
53 53
         }
54 54
     }
@@ -60,10 +60,10 @@  discard block
 block discarded – undo
60 60
     {
61 61
         $fallback = '0.0.0';
62 62
         $majorVersions = [4, 3, 2];
63
-        foreach ($majorVersions as $majorVersion) {
64
-            $settings = get_option(OptionManager::databaseKey($majorVersion));
65
-            $version = glsr_get($settings, 'version', $fallback);
66
-            if (version_compare($version, $fallback, '>')) {
63
+        foreach( $majorVersions as $majorVersion ) {
64
+            $settings = get_option( OptionManager::databaseKey( $majorVersion ) );
65
+            $version = glsr_get( $settings, 'version', $fallback );
66
+            if( version_compare( $version, $fallback, '>' ) ) {
67 67
                 return $version;
68 68
             }
69 69
         }
@@ -75,16 +75,16 @@  discard block
 block discarded – undo
75 75
      */
76 76
     protected function setReviewCounts()
77 77
     {
78
-        add_action('admin_init', 'glsr_calculate_ratings');
78
+        add_action( 'admin_init', 'glsr_calculate_ratings' );
79 79
     }
80 80
 
81 81
     /**
82 82
      * @param string $previousVersion
83 83
      * @return void
84 84
      */
85
-    protected function updateVersionFrom($previousVersion)
85
+    protected function updateVersionFrom( $previousVersion )
86 86
     {
87
-        glsr(OptionManager::class)->set('version', glsr()->version);
88
-        glsr(OptionManager::class)->set('version_upgraded_from', $previousVersion);
87
+        glsr( OptionManager::class )->set( 'version', glsr()->version );
88
+        glsr( OptionManager::class )->set( 'version_upgraded_from', $previousVersion );
89 89
     }
90 90
 }
Please login to merge, or discard this patch.
plugin/Modules/Wpml.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -13,44 +13,44 @@  discard block
 block discarded – undo
13 13
     /**
14 14
      * {@inheritdoc}
15 15
      */
16
-    public function getPost($postId)
16
+    public function getPost( $postId )
17 17
     {
18
-        $postId = trim($postId);
19
-        if (!is_numeric($postId)) {
18
+        $postId = trim( $postId );
19
+        if( !is_numeric( $postId ) ) {
20 20
             return;
21 21
         }
22
-        if ($this->isEnabled()) {
23
-            $postId = apply_filters('wpml_object_id', $postId, 'any', true);
22
+        if( $this->isEnabled() ) {
23
+            $postId = apply_filters( 'wpml_object_id', $postId, 'any', true );
24 24
         }
25
-        return get_post(intval($postId));
25
+        return get_post( intval( $postId ) );
26 26
     }
27 27
 
28 28
     /**
29 29
      * {@inheritdoc}
30 30
      */
31
-    public function getPostIds(array $postIds)
31
+    public function getPostIds( array $postIds )
32 32
     {
33
-        if (!$this->isEnabled()) {
33
+        if( !$this->isEnabled() ) {
34 34
             return $postIds;
35 35
         }
36 36
         $newPostIds = [];
37
-        foreach ($this->cleanIds($postIds) as $postId) {
38
-            $postType = get_post_type($postId);
39
-            if (!$postType) {
37
+        foreach( $this->cleanIds( $postIds ) as $postId ) {
38
+            $postType = get_post_type( $postId );
39
+            if( !$postType ) {
40 40
                 continue;
41 41
             }
42 42
             $elementType = 'post_'.$postType;
43
-            $trid = apply_filters('wpml_element_trid', null, $postId, $elementType);
44
-            $translations = apply_filters('wpml_get_element_translations', null, $trid, $elementType);
45
-            if (!is_array($translations)) {
43
+            $trid = apply_filters( 'wpml_element_trid', null, $postId, $elementType );
44
+            $translations = apply_filters( 'wpml_get_element_translations', null, $trid, $elementType );
45
+            if( !is_array( $translations ) ) {
46 46
                 $translations = [];
47 47
             }
48 48
             $newPostIds = array_merge(
49 49
                 $newPostIds,
50
-                array_column($translations, 'element_id')
50
+                array_column( $translations, 'element_id' )
51 51
             );
52 52
         }
53
-        return $this->cleanIds($newPostIds);
53
+        return $this->cleanIds( $newPostIds );
54 54
     }
55 55
 
56 56
     /**
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
      */
59 59
     public function isActive()
60 60
     {
61
-        return defined('ICL_SITEPRESS_VERSION');
61
+        return defined( 'ICL_SITEPRESS_VERSION' );
62 62
     }
63 63
 
64 64
     /**
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
     public function isEnabled()
68 68
     {
69 69
         return $this->isActive()
70
-            && 'wpml' == glsr(OptionManager::class)->get('settings.general.multilingual');
70
+            && 'wpml' == glsr( OptionManager::class )->get( 'settings.general.multilingual' );
71 71
     }
72 72
 
73 73
     /**
@@ -76,14 +76,14 @@  discard block
 block discarded – undo
76 76
     public function isSupported()
77 77
     {
78 78
         return $this->isActive()
79
-            && version_compare(ICL_SITEPRESS_VERSION, static::SUPPORTED_VERSION, '>=');
79
+            && version_compare( ICL_SITEPRESS_VERSION, static::SUPPORTED_VERSION, '>=' );
80 80
     }
81 81
 
82 82
     /**
83 83
      * @return array
84 84
      */
85
-    protected function cleanIds(array $postIds)
85
+    protected function cleanIds( array $postIds )
86 86
     {
87
-        return array_filter(array_unique($postIds));
87
+        return array_filter( array_unique( $postIds ) );
88 88
     }
89 89
 }
Please login to merge, or discard this patch.
plugin/Modules/Polylang.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -13,37 +13,37 @@  discard block
 block discarded – undo
13 13
     /**
14 14
      * {@inheritdoc}
15 15
      */
16
-    public function getPost($postId)
16
+    public function getPost( $postId )
17 17
     {
18
-        $postId = trim($postId);
19
-        if (!is_numeric($postId)) {
18
+        $postId = trim( $postId );
19
+        if( !is_numeric( $postId ) ) {
20 20
             return;
21 21
         }
22
-        if ($this->isEnabled()) {
23
-            $polylangPostId = pll_get_post($postId, pll_get_post_language(get_the_ID()));
22
+        if( $this->isEnabled() ) {
23
+            $polylangPostId = pll_get_post( $postId, pll_get_post_language( get_the_ID() ) );
24 24
         }
25
-        if (!empty($polylangPostId)) {
25
+        if( !empty($polylangPostId) ) {
26 26
             $postId = $polylangPostId;
27 27
         }
28
-        return get_post(intval($postId));
28
+        return get_post( intval( $postId ) );
29 29
     }
30 30
 
31 31
     /**
32 32
      * {@inheritdoc}
33 33
      */
34
-    public function getPostIds(array $postIds)
34
+    public function getPostIds( array $postIds )
35 35
     {
36
-        if (!$this->isEnabled()) {
36
+        if( !$this->isEnabled() ) {
37 37
             return $postIds;
38 38
         }
39 39
         $newPostIds = [];
40
-        foreach ($this->cleanIds($postIds) as $postId) {
40
+        foreach( $this->cleanIds( $postIds ) as $postId ) {
41 41
             $newPostIds = array_merge(
42 42
                 $newPostIds,
43
-                array_values(pll_get_post_translations($postId))
43
+                array_values( pll_get_post_translations( $postId ) )
44 44
             );
45 45
         }
46
-        return $this->cleanIds($newPostIds);
46
+        return $this->cleanIds( $newPostIds );
47 47
     }
48 48
 
49 49
     /**
@@ -51,10 +51,10 @@  discard block
 block discarded – undo
51 51
      */
52 52
     public function isActive()
53 53
     {
54
-        return function_exists('PLL')
55
-            && function_exists('pll_get_post')
56
-            && function_exists('pll_get_post_language')
57
-            && function_exists('pll_get_post_translations');
54
+        return function_exists( 'PLL' )
55
+            && function_exists( 'pll_get_post' )
56
+            && function_exists( 'pll_get_post_language' )
57
+            && function_exists( 'pll_get_post_translations' );
58 58
     }
59 59
 
60 60
     /**
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
     public function isEnabled()
64 64
     {
65 65
         return $this->isActive()
66
-            && 'polylang' == glsr(OptionManager::class)->get('settings.general.multilingual');
66
+            && 'polylang' == glsr( OptionManager::class )->get( 'settings.general.multilingual' );
67 67
     }
68 68
 
69 69
     /**
@@ -71,15 +71,15 @@  discard block
 block discarded – undo
71 71
      */
72 72
     public function isSupported()
73 73
     {
74
-        return defined('POLYLANG_VERSION')
75
-            && version_compare(POLYLANG_VERSION, static::SUPPORTED_VERSION, '>=');
74
+        return defined( 'POLYLANG_VERSION' )
75
+            && version_compare( POLYLANG_VERSION, static::SUPPORTED_VERSION, '>=' );
76 76
     }
77 77
 
78 78
     /**
79 79
      * @return array
80 80
      */
81
-    protected function cleanIds(array $postIds)
81
+    protected function cleanIds( array $postIds )
82 82
     {
83
-        return array_filter(array_unique($postIds));
83
+        return array_filter( array_unique( $postIds ) );
84 84
     }
85 85
 }
Please login to merge, or discard this patch.
plugin/Modules/Rating.php 1 patch
Spacing   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -45,13 +45,13 @@  discard block
 block discarded – undo
45 45
      * @param int $roundBy
46 46
      * @return float
47 47
      */
48
-    public function getAverage(array $ratingCounts, $roundBy = 1)
48
+    public function getAverage( array $ratingCounts, $roundBy = 1 )
49 49
     {
50
-        $average = array_sum($ratingCounts);
51
-        if ($average > 0) {
52
-            $average = round($this->getTotalSum($ratingCounts) / $average, intval($roundBy));
50
+        $average = array_sum( $ratingCounts );
51
+        if( $average > 0 ) {
52
+            $average = round( $this->getTotalSum( $ratingCounts ) / $average, intval( $roundBy ) );
53 53
         }
54
-        return floatval(apply_filters('site-reviews/rating/average', $average, $ratingCounts));
54
+        return floatval( apply_filters( 'site-reviews/rating/average', $average, $ratingCounts ) );
55 55
     }
56 56
 
57 57
     /**
@@ -64,50 +64,50 @@  discard block
 block discarded – undo
64 64
      * @param int $confidencePercentage
65 65
      * @return int|float
66 66
      */
67
-    public function getLowerBound(array $upDownCounts = [0, 0], $confidencePercentage = 95)
67
+    public function getLowerBound( array $upDownCounts = [0, 0], $confidencePercentage = 95 )
68 68
     {
69
-        $numRatings = array_sum($upDownCounts);
70
-        if ($numRatings < 1) {
69
+        $numRatings = array_sum( $upDownCounts );
70
+        if( $numRatings < 1 ) {
71 71
             return 0;
72 72
         }
73 73
         $z = static::CONFIDENCE_LEVEL_Z_SCORES[$confidencePercentage];
74 74
         $phat = 1 * $upDownCounts[1] / $numRatings;
75
-        return ($phat + $z * $z / (2 * $numRatings) - $z * sqrt(($phat * (1 - $phat) + $z * $z / (4 * $numRatings)) / $numRatings)) / (1 + $z * $z / $numRatings);
75
+        return ($phat + $z * $z / (2 * $numRatings) - $z * sqrt( ($phat * (1 - $phat) + $z * $z / (4 * $numRatings)) / $numRatings )) / (1 + $z * $z / $numRatings);
76 76
     }
77 77
 
78 78
     /**
79 79
      * @return int|float
80 80
      */
81
-    public function getOverallPercentage(array $ratingCounts)
81
+    public function getOverallPercentage( array $ratingCounts )
82 82
     {
83
-        return round($this->getAverage($ratingCounts) * 100 / glsr()->constant('MAX_RATING', __CLASS__), 2);
83
+        return round( $this->getAverage( $ratingCounts ) * 100 / glsr()->constant( 'MAX_RATING', __CLASS__ ), 2 );
84 84
     }
85 85
 
86 86
     /**
87 87
      * @return array
88 88
      */
89
-    public function getPercentages(array $ratingCounts)
89
+    public function getPercentages( array $ratingCounts )
90 90
     {
91
-        $total = array_sum($ratingCounts);
92
-        foreach ($ratingCounts as $index => $count) {
93
-            if (empty($count)) {
91
+        $total = array_sum( $ratingCounts );
92
+        foreach( $ratingCounts as $index => $count ) {
93
+            if( empty($count) ) {
94 94
                 continue;
95 95
             }
96 96
             $ratingCounts[$index] = $count / $total * 100;
97 97
         }
98
-        return $this->getRoundedPercentages($ratingCounts);
98
+        return $this->getRoundedPercentages( $ratingCounts );
99 99
     }
100 100
 
101 101
     /**
102 102
      * @return float
103 103
      */
104
-    public function getRanking(array $ratingCounts)
104
+    public function getRanking( array $ratingCounts )
105 105
     {
106
-        return floatval(apply_filters('site-reviews/rating/ranking',
107
-            $this->getRankingUsingImdb($ratingCounts),
106
+        return floatval( apply_filters( 'site-reviews/rating/ranking',
107
+            $this->getRankingUsingImdb( $ratingCounts ),
108 108
             $ratingCounts,
109 109
             $this
110
-        ));
110
+        ) );
111 111
     }
112 112
 
113 113
     /**
@@ -120,15 +120,15 @@  discard block
 block discarded – undo
120 120
      * @param int $confidencePercentage
121 121
      * @return int|float
122 122
      */
123
-    public function getRankingUsingImdb(array $ratingCounts, $confidencePercentage = 70)
123
+    public function getRankingUsingImdb( array $ratingCounts, $confidencePercentage = 70 )
124 124
     {
125
-        $avgRating = $this->getAverage($ratingCounts);
125
+        $avgRating = $this->getAverage( $ratingCounts );
126 126
         // Represents a prior (your prior opinion without data) for the average star rating. A higher prior also means a higher margin for error.
127 127
         // This could also be the average score of all items instead of a fixed value.
128
-        $bayesMean = ($confidencePercentage / 100) * glsr()->constant('MAX_RATING', __CLASS__); // prior, 70% = 3.5
128
+        $bayesMean = ($confidencePercentage / 100) * glsr()->constant( 'MAX_RATING', __CLASS__ ); // prior, 70% = 3.5
129 129
         // Represents the number of ratings expected to begin observing a pattern that would put confidence in the prior.
130 130
         $bayesMinimal = 10; // confidence
131
-        $numOfReviews = array_sum($ratingCounts);
131
+        $numOfReviews = array_sum( $ratingCounts );
132 132
         return $avgRating > 0
133 133
             ? (($bayesMinimal * $bayesMean) + ($avgRating * $numOfReviews)) / ($bayesMinimal + $numOfReviews)
134 134
             : 0;
@@ -144,48 +144,48 @@  discard block
 block discarded – undo
144 144
      * @param int $confidencePercentage
145 145
      * @return float
146 146
      */
147
-    public function getRankingUsingZScores(array $ratingCounts, $confidencePercentage = 90)
147
+    public function getRankingUsingZScores( array $ratingCounts, $confidencePercentage = 90 )
148 148
     {
149
-        $ratingCountsSum = array_sum($ratingCounts) + glsr()->constant('MAX_RATING', __CLASS__);
150
-        $weight = $this->getWeight($ratingCounts, $ratingCountsSum);
151
-        $weightPow2 = $this->getWeight($ratingCounts, $ratingCountsSum, true);
149
+        $ratingCountsSum = array_sum( $ratingCounts ) + glsr()->constant( 'MAX_RATING', __CLASS__ );
150
+        $weight = $this->getWeight( $ratingCounts, $ratingCountsSum );
151
+        $weightPow2 = $this->getWeight( $ratingCounts, $ratingCountsSum, true );
152 152
         $zScore = static::CONFIDENCE_LEVEL_Z_SCORES[$confidencePercentage];
153
-        return $weight - $zScore * sqrt(($weightPow2 - pow($weight, 2)) / ($ratingCountsSum + 1));
153
+        return $weight - $zScore * sqrt( ($weightPow2 - pow( $weight, 2 )) / ($ratingCountsSum + 1) );
154 154
     }
155 155
 
156 156
     /**
157 157
      * @param int $target
158 158
      * @return array
159 159
      */
160
-    protected function getRoundedPercentages(array $percentages, $totalPercent = 100)
160
+    protected function getRoundedPercentages( array $percentages, $totalPercent = 100 )
161 161
     {
162
-        array_walk($percentages, function (&$percent, $index) {
162
+        array_walk( $percentages, function( &$percent, $index ) {
163 163
             $percent = [
164 164
                 'index' => $index,
165
-                'percent' => floor($percent),
166
-                'remainder' => fmod($percent, 1),
165
+                'percent' => floor( $percent ),
166
+                'remainder' => fmod( $percent, 1 ),
167 167
             ];
168 168
         });
169
-        $indexes = glsr_array_column($percentages, 'index');
170
-        $remainders = glsr_array_column($percentages, 'remainder');
171
-        array_multisort($remainders, SORT_DESC, SORT_STRING, $indexes, SORT_DESC, $percentages);
169
+        $indexes = glsr_array_column( $percentages, 'index' );
170
+        $remainders = glsr_array_column( $percentages, 'remainder' );
171
+        array_multisort( $remainders, SORT_DESC, SORT_STRING, $indexes, SORT_DESC, $percentages );
172 172
         $i = 0;
173
-        if (array_sum(glsr_array_column($percentages, 'percent')) > 0) {
174
-            while (array_sum(glsr_array_column($percentages, 'percent')) < $totalPercent) {
173
+        if( array_sum( glsr_array_column( $percentages, 'percent' ) ) > 0 ) {
174
+            while( array_sum( glsr_array_column( $percentages, 'percent' ) ) < $totalPercent ) {
175 175
                 ++$percentages[$i]['percent'];
176 176
                 ++$i;
177 177
             }
178 178
         }
179
-        array_multisort($indexes, SORT_DESC, $percentages);
180
-        return array_combine($indexes, glsr_array_column($percentages, 'percent'));
179
+        array_multisort( $indexes, SORT_DESC, $percentages );
180
+        return array_combine( $indexes, glsr_array_column( $percentages, 'percent' ) );
181 181
     }
182 182
 
183 183
     /**
184 184
      * @return int
185 185
      */
186
-    protected function getTotalSum(array $ratingCounts)
186
+    protected function getTotalSum( array $ratingCounts )
187 187
     {
188
-        return array_reduce(array_keys($ratingCounts), function ($carry, $index) use ($ratingCounts) {
188
+        return array_reduce( array_keys( $ratingCounts ), function( $carry, $index ) use ($ratingCounts) {
189 189
             return $carry + ($index * $ratingCounts[$index]);
190 190
         });
191 191
     }
@@ -195,12 +195,12 @@  discard block
 block discarded – undo
195 195
      * @param bool $powerOf2
196 196
      * @return float
197 197
      */
198
-    protected function getWeight(array $ratingCounts, $ratingCountsSum, $powerOf2 = false)
198
+    protected function getWeight( array $ratingCounts, $ratingCountsSum, $powerOf2 = false )
199 199
     {
200
-        return array_reduce(array_keys($ratingCounts),
201
-            function ($count, $rating) use ($ratingCounts, $ratingCountsSum, $powerOf2) {
200
+        return array_reduce( array_keys( $ratingCounts ),
201
+            function( $count, $rating ) use ($ratingCounts, $ratingCountsSum, $powerOf2) {
202 202
                 $ratingLevel = $powerOf2
203
-                    ? pow($rating, 2)
203
+                    ? pow( $rating, 2 )
204 204
                     : $rating;
205 205
                 return $count + ($ratingLevel * ($ratingCounts[$rating] + 1)) / $ratingCountsSum;
206 206
             }
Please login to merge, or discard this patch.