Passed
Push — feature/rebusify ( 495106...67b08f )
by Paul
06:10 queued 02:03
created
plugin/Helper.php 2 patches
Indentation   +115 added lines, -115 removed lines patch added patch discarded remove patch
@@ -9,126 +9,126 @@
 block discarded – undo
9 9
 
10 10
 class Helper
11 11
 {
12
-    use Arr;
13
-    use Str;
12
+	use Arr;
13
+	use Str;
14 14
 
15
-    /**
16
-     * @param string $name
17
-     * @param string $path
18
-     * @return string
19
-     */
20
-    public function buildClassName($name, $path = '')
21
-    {
22
-        $className = $this->camelCase($name);
23
-        $path = ltrim(str_replace(__NAMESPACE__, '', $path), '\\');
24
-        return !empty($path)
25
-            ? __NAMESPACE__.'\\'.$path.'\\'.$className
26
-            : $className;
27
-    }
15
+	/**
16
+	 * @param string $name
17
+	 * @param string $path
18
+	 * @return string
19
+	 */
20
+	public function buildClassName($name, $path = '')
21
+	{
22
+		$className = $this->camelCase($name);
23
+		$path = ltrim(str_replace(__NAMESPACE__, '', $path), '\\');
24
+		return !empty($path)
25
+			? __NAMESPACE__.'\\'.$path.'\\'.$className
26
+			: $className;
27
+	}
28 28
 
29
-    /**
30
-     * @param string $name
31
-     * @param string $prefix
32
-     * @return string
33
-     */
34
-    public function buildMethodName($name, $prefix = '')
35
-    {
36
-        return lcfirst($prefix.$this->buildClassName($name));
37
-    }
29
+	/**
30
+	 * @param string $name
31
+	 * @param string $prefix
32
+	 * @return string
33
+	 */
34
+	public function buildMethodName($name, $prefix = '')
35
+	{
36
+		return lcfirst($prefix.$this->buildClassName($name));
37
+	}
38 38
 
39
-    /**
40
-     * @param string $name
41
-     * @return string
42
-     */
43
-    public function buildPropertyName($name)
44
-    {
45
-        return lcfirst($this->buildClassName($name));
46
-    }
39
+	/**
40
+	 * @param string $name
41
+	 * @return string
42
+	 */
43
+	public function buildPropertyName($name)
44
+	{
45
+		return lcfirst($this->buildClassName($name));
46
+	}
47 47
 
48
-    /**
49
-     * @param string $cast
50
-     * @param mixed $value
51
-     * @return mixed
52
-     */
53
-    public function castTo($cast = '', $value)
54
-    {
55
-        switch ($cast) {
56
-            case 'array':
57
-                return (array) $value;
58
-            case 'boolean':
59
-                if ('no' === $value) {
60
-                    return false;
61
-                }
62
-                return (bool) $value;
63
-            case 'integer':
64
-                if (is_numeric($value) || is_string($value)) {
65
-                    return (int) $value;
66
-                }
67
-                // no break
68
-            case 'object':
69
-                return (object) (array) $value;
70
-            case 'string':
71
-                if (!is_array($value) && !is_object($value)) {
72
-                    return (string) $value;
73
-                }
74
-                // no break
75
-            default:
76
-                return $value;
77
-        }
78
-    }
48
+	/**
49
+	 * @param string $cast
50
+	 * @param mixed $value
51
+	 * @return mixed
52
+	 */
53
+	public function castTo($cast = '', $value)
54
+	{
55
+		switch ($cast) {
56
+			case 'array':
57
+				return (array) $value;
58
+			case 'boolean':
59
+				if ('no' === $value) {
60
+					return false;
61
+				}
62
+				return (bool) $value;
63
+			case 'integer':
64
+				if (is_numeric($value) || is_string($value)) {
65
+					return (int) $value;
66
+				}
67
+				// no break
68
+			case 'object':
69
+				return (object) (array) $value;
70
+			case 'string':
71
+				if (!is_array($value) && !is_object($value)) {
72
+					return (string) $value;
73
+				}
74
+				// no break
75
+			default:
76
+				return $value;
77
+		}
78
+	}
79 79
 
80
-    /**
81
-     * @param string $key
82
-     * @return mixed
83
-     */
84
-    public function filterInput($key, array $request = [])
85
-    {
86
-        if (isset($request[$key])) {
87
-            return $request[$key];
88
-        }
89
-        $variable = filter_input(INPUT_POST, $key);
90
-        if (is_null($variable) && isset($_POST[$key])) {
91
-            $variable = $_POST[$key];
92
-        }
93
-        return $variable;
94
-    }
80
+	/**
81
+	 * @param string $key
82
+	 * @return mixed
83
+	 */
84
+	public function filterInput($key, array $request = [])
85
+	{
86
+		if (isset($request[$key])) {
87
+			return $request[$key];
88
+		}
89
+		$variable = filter_input(INPUT_POST, $key);
90
+		if (is_null($variable) && isset($_POST[$key])) {
91
+			$variable = $_POST[$key];
92
+		}
93
+		return $variable;
94
+	}
95 95
 
96
-    /**
97
-     * @param string $key
98
-     * @return array
99
-     */
100
-    public function filterInputArray($key)
101
-    {
102
-        $variable = filter_input(INPUT_POST, $key, FILTER_DEFAULT, FILTER_REQUIRE_ARRAY);
103
-        if (empty($variable) && !empty($_POST[$key]) && is_array($_POST[$key])) {
104
-            $variable = $_POST[$key];
105
-        }
106
-        return (array) $variable;
107
-    }
96
+	/**
97
+	 * @param string $key
98
+	 * @return array
99
+	 */
100
+	public function filterInputArray($key)
101
+	{
102
+		$variable = filter_input(INPUT_POST, $key, FILTER_DEFAULT, FILTER_REQUIRE_ARRAY);
103
+		if (empty($variable) && !empty($_POST[$key]) && is_array($_POST[$key])) {
104
+			$variable = $_POST[$key];
105
+		}
106
+		return (array) $variable;
107
+	}
108 108
 
109
-    /**
110
-     * @return string
111
-     */
112
-    public function getIpAddress()
113
-    {
114
-        $cloudflareIps = glsr(Cache::class)->getCloudflareIps();
115
-        $ipv6 = defined('AF_INET6')
116
-            ? $cloudflareIps['v6']
117
-            : [];
118
-        $whitelist = apply_filters('site-reviews/whip/whitelist', [
119
-            Whip::CLOUDFLARE_HEADERS => [
120
-                Whip::IPV4 => $cloudflareIps['v4'],
121
-                Whip::IPV6 => $ipv6,
122
-            ],
123
-            Whip::CUSTOM_HEADERS => [
124
-                Whip::IPV4 => ['127.0.0.1'],
125
-                Whip::IPV6 => ['::1'],
126
-            ],
127
-        ]);
128
-        $methods = Whip::CUSTOM_HEADERS | Whip::CLOUDFLARE_HEADERS | Whip::REMOTE_ADDR;
129
-        $methods = apply_filters('site-reviews/whip/methods', $methods);
130
-        $whip = new Whip($methods, $whitelist);
131
-        do_action_ref_array('site-reviews/whip', [$whip]);
132
-        return (string) $whip->getValidIpAddress();
133
-    }
109
+	/**
110
+	 * @return string
111
+	 */
112
+	public function getIpAddress()
113
+	{
114
+		$cloudflareIps = glsr(Cache::class)->getCloudflareIps();
115
+		$ipv6 = defined('AF_INET6')
116
+			? $cloudflareIps['v6']
117
+			: [];
118
+		$whitelist = apply_filters('site-reviews/whip/whitelist', [
119
+			Whip::CLOUDFLARE_HEADERS => [
120
+				Whip::IPV4 => $cloudflareIps['v4'],
121
+				Whip::IPV6 => $ipv6,
122
+			],
123
+			Whip::CUSTOM_HEADERS => [
124
+				Whip::IPV4 => ['127.0.0.1'],
125
+				Whip::IPV6 => ['::1'],
126
+			],
127
+		]);
128
+		$methods = Whip::CUSTOM_HEADERS | Whip::CLOUDFLARE_HEADERS | Whip::REMOTE_ADDR;
129
+		$methods = apply_filters('site-reviews/whip/methods', $methods);
130
+		$whip = new Whip($methods, $whitelist);
131
+		do_action_ref_array('site-reviews/whip', [$whip]);
132
+		return (string) $whip->getValidIpAddress();
133
+	}
134 134
 }
Please login to merge, or discard this patch.
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -17,10 +17,10 @@  discard block
 block discarded – undo
17 17
      * @param string $path
18 18
      * @return string
19 19
      */
20
-    public function buildClassName($name, $path = '')
20
+    public function buildClassName( $name, $path = '' )
21 21
     {
22
-        $className = $this->camelCase($name);
23
-        $path = ltrim(str_replace(__NAMESPACE__, '', $path), '\\');
22
+        $className = $this->camelCase( $name );
23
+        $path = ltrim( str_replace( __NAMESPACE__, '', $path ), '\\' );
24 24
         return !empty($path)
25 25
             ? __NAMESPACE__.'\\'.$path.'\\'.$className
26 26
             : $className;
@@ -31,18 +31,18 @@  discard block
 block discarded – undo
31 31
      * @param string $prefix
32 32
      * @return string
33 33
      */
34
-    public function buildMethodName($name, $prefix = '')
34
+    public function buildMethodName( $name, $prefix = '' )
35 35
     {
36
-        return lcfirst($prefix.$this->buildClassName($name));
36
+        return lcfirst( $prefix.$this->buildClassName( $name ) );
37 37
     }
38 38
 
39 39
     /**
40 40
      * @param string $name
41 41
      * @return string
42 42
      */
43
-    public function buildPropertyName($name)
43
+    public function buildPropertyName( $name )
44 44
     {
45
-        return lcfirst($this->buildClassName($name));
45
+        return lcfirst( $this->buildClassName( $name ) );
46 46
     }
47 47
 
48 48
     /**
@@ -50,26 +50,26 @@  discard block
 block discarded – undo
50 50
      * @param mixed $value
51 51
      * @return mixed
52 52
      */
53
-    public function castTo($cast = '', $value)
53
+    public function castTo( $cast = '', $value )
54 54
     {
55
-        switch ($cast) {
55
+        switch( $cast ) {
56 56
             case 'array':
57
-                return (array) $value;
57
+                return (array)$value;
58 58
             case 'boolean':
59
-                if ('no' === $value) {
59
+                if( 'no' === $value ) {
60 60
                     return false;
61 61
                 }
62
-                return (bool) $value;
62
+                return (bool)$value;
63 63
             case 'integer':
64
-                if (is_numeric($value) || is_string($value)) {
65
-                    return (int) $value;
64
+                if( is_numeric( $value ) || is_string( $value ) ) {
65
+                    return (int)$value;
66 66
                 }
67 67
                 // no break
68 68
             case 'object':
69
-                return (object) (array) $value;
69
+                return (object)(array)$value;
70 70
             case 'string':
71
-                if (!is_array($value) && !is_object($value)) {
72
-                    return (string) $value;
71
+                if( !is_array( $value ) && !is_object( $value ) ) {
72
+                    return (string)$value;
73 73
                 }
74 74
                 // no break
75 75
             default:
@@ -81,13 +81,13 @@  discard block
 block discarded – undo
81 81
      * @param string $key
82 82
      * @return mixed
83 83
      */
84
-    public function filterInput($key, array $request = [])
84
+    public function filterInput( $key, array $request = [] )
85 85
     {
86
-        if (isset($request[$key])) {
86
+        if( isset($request[$key]) ) {
87 87
             return $request[$key];
88 88
         }
89
-        $variable = filter_input(INPUT_POST, $key);
90
-        if (is_null($variable) && isset($_POST[$key])) {
89
+        $variable = filter_input( INPUT_POST, $key );
90
+        if( is_null( $variable ) && isset($_POST[$key]) ) {
91 91
             $variable = $_POST[$key];
92 92
         }
93 93
         return $variable;
@@ -97,13 +97,13 @@  discard block
 block discarded – undo
97 97
      * @param string $key
98 98
      * @return array
99 99
      */
100
-    public function filterInputArray($key)
100
+    public function filterInputArray( $key )
101 101
     {
102
-        $variable = filter_input(INPUT_POST, $key, FILTER_DEFAULT, FILTER_REQUIRE_ARRAY);
103
-        if (empty($variable) && !empty($_POST[$key]) && is_array($_POST[$key])) {
102
+        $variable = filter_input( INPUT_POST, $key, FILTER_DEFAULT, FILTER_REQUIRE_ARRAY );
103
+        if( empty($variable) && !empty($_POST[$key]) && is_array( $_POST[$key] ) ) {
104 104
             $variable = $_POST[$key];
105 105
         }
106
-        return (array) $variable;
106
+        return (array)$variable;
107 107
     }
108 108
 
109 109
     /**
@@ -111,11 +111,11 @@  discard block
 block discarded – undo
111 111
      */
112 112
     public function getIpAddress()
113 113
     {
114
-        $cloudflareIps = glsr(Cache::class)->getCloudflareIps();
115
-        $ipv6 = defined('AF_INET6')
114
+        $cloudflareIps = glsr( Cache::class )->getCloudflareIps();
115
+        $ipv6 = defined( 'AF_INET6' )
116 116
             ? $cloudflareIps['v6']
117 117
             : [];
118
-        $whitelist = apply_filters('site-reviews/whip/whitelist', [
118
+        $whitelist = apply_filters( 'site-reviews/whip/whitelist', [
119 119
             Whip::CLOUDFLARE_HEADERS => [
120 120
                 Whip::IPV4 => $cloudflareIps['v4'],
121 121
                 Whip::IPV6 => $ipv6,
@@ -124,11 +124,11 @@  discard block
 block discarded – undo
124 124
                 Whip::IPV4 => ['127.0.0.1'],
125 125
                 Whip::IPV6 => ['::1'],
126 126
             ],
127
-        ]);
127
+        ] );
128 128
         $methods = Whip::CUSTOM_HEADERS | Whip::CLOUDFLARE_HEADERS | Whip::REMOTE_ADDR;
129
-        $methods = apply_filters('site-reviews/whip/methods', $methods);
130
-        $whip = new Whip($methods, $whitelist);
131
-        do_action_ref_array('site-reviews/whip', [$whip]);
132
-        return (string) $whip->getValidIpAddress();
129
+        $methods = apply_filters( 'site-reviews/whip/methods', $methods );
130
+        $whip = new Whip( $methods, $whitelist );
131
+        do_action_ref_array( 'site-reviews/whip', [$whip] );
132
+        return (string)$whip->getValidIpAddress();
133 133
     }
134 134
 }
Please login to merge, or discard this patch.
plugin/HelperTraits/Str.php 2 patches
Indentation   +96 added lines, -96 removed lines patch added patch discarded remove patch
@@ -4,108 +4,108 @@
 block discarded – undo
4 4
 
5 5
 trait Str
6 6
 {
7
-    /**
8
-     * @param string $string
9
-     * @return string
10
-     */
11
-    public function camelCase($string)
12
-    {
13
-        $string = ucwords(str_replace(['-', '_'], ' ', trim($string)));
14
-        return str_replace(' ', '', $string);
15
-    }
7
+	/**
8
+	 * @param string $string
9
+	 * @return string
10
+	 */
11
+	public function camelCase($string)
12
+	{
13
+		$string = ucwords(str_replace(['-', '_'], ' ', trim($string)));
14
+		return str_replace(' ', '', $string);
15
+	}
16 16
 
17
-    /**
18
-     * @param string $name
19
-     * @return string
20
-     */
21
-    public function convertPathToId($path, $prefix = '')
22
-    {
23
-        return str_replace(['[', ']'], ['-', ''], $this->convertPathToName($path, $prefix));
24
-    }
17
+	/**
18
+	 * @param string $name
19
+	 * @return string
20
+	 */
21
+	public function convertPathToId($path, $prefix = '')
22
+	{
23
+		return str_replace(['[', ']'], ['-', ''], $this->convertPathToName($path, $prefix));
24
+	}
25 25
 
26
-    /**
27
-     * @param string $path
28
-     * @return string
29
-     */
30
-    public function convertPathToName($path, $prefix = '')
31
-    {
32
-        $levels = explode('.', $path);
33
-        return array_reduce($levels, function ($result, $value) {
34
-            return $result .= '['.$value.']';
35
-        }, $prefix);
36
-    }
26
+	/**
27
+	 * @param string $path
28
+	 * @return string
29
+	 */
30
+	public function convertPathToName($path, $prefix = '')
31
+	{
32
+		$levels = explode('.', $path);
33
+		return array_reduce($levels, function ($result, $value) {
34
+			return $result .= '['.$value.']';
35
+		}, $prefix);
36
+	}
37 37
 
38
-    /**
39
-     * @param string $string
40
-     * @return string
41
-     */
42
-    public function dashCase($string)
43
-    {
44
-        return str_replace('_', '-', $this->snakeCase($string));
45
-    }
38
+	/**
39
+	 * @param string $string
40
+	 * @return string
41
+	 */
42
+	public function dashCase($string)
43
+	{
44
+		return str_replace('_', '-', $this->snakeCase($string));
45
+	}
46 46
 
47
-    /**
48
-     * @param string $needle
49
-     * @param string $haystack
50
-     * @return bool
51
-     */
52
-    public function endsWith($needle, $haystack)
53
-    {
54
-        $length = strlen($needle);
55
-        return 0 != $length
56
-            ? substr($haystack, -$length) === $needle
57
-            : true;
58
-    }
47
+	/**
48
+	 * @param string $needle
49
+	 * @param string $haystack
50
+	 * @return bool
51
+	 */
52
+	public function endsWith($needle, $haystack)
53
+	{
54
+		$length = strlen($needle);
55
+		return 0 != $length
56
+			? substr($haystack, -$length) === $needle
57
+			: true;
58
+	}
59 59
 
60
-    /**
61
-     * @param string $prefix
62
-     * @param string $string
63
-     * @param string|null $trim
64
-     * @return string
65
-     */
66
-    public function prefix($prefix, $string, $trim = null)
67
-    {
68
-        if (null === $trim) {
69
-            $trim = $prefix;
70
-        }
71
-        return $prefix.trim($this->removePrefix($trim, $string));
72
-    }
60
+	/**
61
+	 * @param string $prefix
62
+	 * @param string $string
63
+	 * @param string|null $trim
64
+	 * @return string
65
+	 */
66
+	public function prefix($prefix, $string, $trim = null)
67
+	{
68
+		if (null === $trim) {
69
+			$trim = $prefix;
70
+		}
71
+		return $prefix.trim($this->removePrefix($trim, $string));
72
+	}
73 73
 
74
-    /**
75
-     * @param string $prefix
76
-     * @param string $string
77
-     * @return string
78
-     */
79
-    public function removePrefix($prefix, $string)
80
-    {
81
-        return $this->startsWith($prefix, $string)
82
-            ? substr($string, strlen($prefix))
83
-            : $string;
84
-    }
74
+	/**
75
+	 * @param string $prefix
76
+	 * @param string $string
77
+	 * @return string
78
+	 */
79
+	public function removePrefix($prefix, $string)
80
+	{
81
+		return $this->startsWith($prefix, $string)
82
+			? substr($string, strlen($prefix))
83
+			: $string;
84
+	}
85 85
 
86
-    /**
87
-     * @param string $string
88
-     * @return string
89
-     */
90
-    public function snakeCase($string)
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);
98
-        }
99
-        return str_replace('-', '_', $string);
100
-    }
86
+	/**
87
+	 * @param string $string
88
+	 * @return string
89
+	 */
90
+	public function snakeCase($string)
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);
98
+		}
99
+		return str_replace('-', '_', $string);
100
+	}
101 101
 
102
-    /**
103
-     * @param string $needle
104
-     * @param string $haystack
105
-     * @return bool
106
-     */
107
-    public function startsWith($needle, $haystack)
108
-    {
109
-        return substr($haystack, 0, strlen($needle)) === $needle;
110
-    }
102
+	/**
103
+	 * @param string $needle
104
+	 * @param string $haystack
105
+	 * @return bool
106
+	 */
107
+	public function startsWith($needle, $haystack)
108
+	{
109
+		return substr($haystack, 0, strlen($needle)) === $needle;
110
+	}
111 111
 }
Please login to merge, or discard this 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/Database/OptionManager.php 2 patches
Indentation   +140 added lines, -140 removed lines patch added patch discarded remove patch
@@ -7,155 +7,155 @@
 block discarded – undo
7 7
 
8 8
 class OptionManager
9 9
 {
10
-    /**
11
-     * @var array
12
-     */
13
-    protected $options;
10
+	/**
11
+	 * @var array
12
+	 */
13
+	protected $options;
14 14
 
15
-    /**
16
-     * @return string
17
-     */
18
-    public static function databaseKey($version = null)
19
-    {
20
-        if (null === $version) {
21
-            $version = explode('.', glsr()->version);
22
-            $version = array_shift($version);
23
-        }
24
-        return glsr(Helper::class)->snakeCase(
25
-            Application::ID.'-v'.intval($version)
26
-        );
27
-    }
15
+	/**
16
+	 * @return string
17
+	 */
18
+	public static function databaseKey($version = null)
19
+	{
20
+		if (null === $version) {
21
+			$version = explode('.', glsr()->version);
22
+			$version = array_shift($version);
23
+		}
24
+		return glsr(Helper::class)->snakeCase(
25
+			Application::ID.'-v'.intval($version)
26
+		);
27
+	}
28 28
 
29
-    /**
30
-     * @return array
31
-     */
32
-    public function all()
33
-    {
34
-        if (empty($this->options)) {
35
-            $this->reset();
36
-        }
37
-        return $this->options;
38
-    }
29
+	/**
30
+	 * @return array
31
+	 */
32
+	public function all()
33
+	{
34
+		if (empty($this->options)) {
35
+			$this->reset();
36
+		}
37
+		return $this->options;
38
+	}
39 39
 
40
-    /**
41
-     * @param string $path
42
-     * @return bool
43
-     */
44
-    public function delete($path)
45
-    {
46
-        $keys = explode('.', $path);
47
-        $last = array_pop($keys);
48
-        $options = $this->all();
49
-        $pointer = &$options;
50
-        foreach ($keys as $key) {
51
-            if (!isset($pointer[$key]) || !is_array($pointer[$key])) {
52
-                continue;
53
-            }
54
-            $pointer = &$pointer[$key];
55
-        }
56
-        unset($pointer[$last]);
57
-        return $this->set($options);
58
-    }
40
+	/**
41
+	 * @param string $path
42
+	 * @return bool
43
+	 */
44
+	public function delete($path)
45
+	{
46
+		$keys = explode('.', $path);
47
+		$last = array_pop($keys);
48
+		$options = $this->all();
49
+		$pointer = &$options;
50
+		foreach ($keys as $key) {
51
+			if (!isset($pointer[$key]) || !is_array($pointer[$key])) {
52
+				continue;
53
+			}
54
+			$pointer = &$pointer[$key];
55
+		}
56
+		unset($pointer[$last]);
57
+		return $this->set($options);
58
+	}
59 59
 
60
-    /**
61
-     * @param string $path
62
-     * @param mixed $fallback
63
-     * @param string $cast
64
-     * @return mixed
65
-     */
66
-    public function get($path = '', $fallback = '', $cast = '')
67
-    {
68
-        $result = glsr(Helper::class)->dataGet($this->all(), $path, $fallback);
69
-        return glsr(Helper::class)->castTo($cast, $result);
70
-    }
60
+	/**
61
+	 * @param string $path
62
+	 * @param mixed $fallback
63
+	 * @param string $cast
64
+	 * @return mixed
65
+	 */
66
+	public function get($path = '', $fallback = '', $cast = '')
67
+	{
68
+		$result = glsr(Helper::class)->dataGet($this->all(), $path, $fallback);
69
+		return glsr(Helper::class)->castTo($cast, $result);
70
+	}
71 71
 
72
-    /**
73
-     * @param string $path
74
-     * @return bool
75
-     */
76
-    public function getBool($path)
77
-    {
78
-        return 'yes' == $this->get($path)
79
-            ? true
80
-            : false;
81
-    }
72
+	/**
73
+	 * @param string $path
74
+	 * @return bool
75
+	 */
76
+	public function getBool($path)
77
+	{
78
+		return 'yes' == $this->get($path)
79
+			? true
80
+			: false;
81
+	}
82 82
 
83
-    /**
84
-     * @param string $path
85
-     * @param mixed $fallback
86
-     * @param string $cast
87
-     * @return mixed
88
-     */
89
-    public function getWP($path, $fallback = '', $cast = '')
90
-    {
91
-        $option = get_option($path, $fallback);
92
-        if (empty($option)) {
93
-            $option = $fallback;
94
-        }
95
-        return glsr(Helper::class)->castTo($cast, $option);
96
-    }
83
+	/**
84
+	 * @param string $path
85
+	 * @param mixed $fallback
86
+	 * @param string $cast
87
+	 * @return mixed
88
+	 */
89
+	public function getWP($path, $fallback = '', $cast = '')
90
+	{
91
+		$option = get_option($path, $fallback);
92
+		if (empty($option)) {
93
+			$option = $fallback;
94
+		}
95
+		return glsr(Helper::class)->castTo($cast, $option);
96
+	}
97 97
 
98
-    /**
99
-     * @return string
100
-     */
101
-    public function json()
102
-    {
103
-        return json_encode($this->all());
104
-    }
98
+	/**
99
+	 * @return string
100
+	 */
101
+	public function json()
102
+	{
103
+		return json_encode($this->all());
104
+	}
105 105
 
106
-    /**
107
-     * @return array
108
-     */
109
-    public function normalize(array $options = [])
110
-    {
111
-        $options = wp_parse_args(
112
-            glsr(Helper::class)->flattenArray($options),
113
-            glsr(DefaultsManager::class)->defaults()
114
-        );
115
-        array_walk($options, function (&$value) {
116
-            if (!is_string($value)) {
117
-                return;
118
-            }
119
-            $value = wp_kses($value, wp_kses_allowed_html('post'));
120
-        });
121
-        return glsr(Helper::class)->convertDotNotationArray($options);
122
-    }
106
+	/**
107
+	 * @return array
108
+	 */
109
+	public function normalize(array $options = [])
110
+	{
111
+		$options = wp_parse_args(
112
+			glsr(Helper::class)->flattenArray($options),
113
+			glsr(DefaultsManager::class)->defaults()
114
+		);
115
+		array_walk($options, function (&$value) {
116
+			if (!is_string($value)) {
117
+				return;
118
+			}
119
+			$value = wp_kses($value, wp_kses_allowed_html('post'));
120
+		});
121
+		return glsr(Helper::class)->convertDotNotationArray($options);
122
+	}
123 123
 
124
-    /**
125
-     * @return bool
126
-     */
127
-    public function isRecaptchaEnabled()
128
-    {
129
-        $integration = $this->get('settings.submissions.recaptcha.integration');
130
-        return 'all' == $integration || ('guest' == $integration && !is_user_logged_in());
131
-    }
124
+	/**
125
+	 * @return bool
126
+	 */
127
+	public function isRecaptchaEnabled()
128
+	{
129
+		$integration = $this->get('settings.submissions.recaptcha.integration');
130
+		return 'all' == $integration || ('guest' == $integration && !is_user_logged_in());
131
+	}
132 132
 
133
-    /**
134
-     * @return array
135
-     */
136
-    public function reset()
137
-    {
138
-        $options = $this->getWP(static::databaseKey(), []);
139
-        if (!is_array($options) || empty($options)) {
140
-            delete_option(static::databaseKey());
141
-            $options = glsr()->defaults;
142
-        }
143
-        $this->options = $options;
144
-    }
133
+	/**
134
+	 * @return array
135
+	 */
136
+	public function reset()
137
+	{
138
+		$options = $this->getWP(static::databaseKey(), []);
139
+		if (!is_array($options) || empty($options)) {
140
+			delete_option(static::databaseKey());
141
+			$options = glsr()->defaults;
142
+		}
143
+		$this->options = $options;
144
+	}
145 145
 
146
-    /**
147
-     * @param string|array $pathOrOptions
148
-     * @param mixed $value
149
-     * @return bool
150
-     */
151
-    public function set($pathOrOptions, $value = '')
152
-    {
153
-        if (is_string($pathOrOptions)) {
154
-            $pathOrOptions = glsr(Helper::class)->dataSet($this->all(), $pathOrOptions, $value);
155
-        }
156
-        if ($result = update_option(static::databaseKey(), (array) $pathOrOptions)) {
157
-            $this->reset();
158
-        }
159
-        return $result;
160
-    }
146
+	/**
147
+	 * @param string|array $pathOrOptions
148
+	 * @param mixed $value
149
+	 * @return bool
150
+	 */
151
+	public function set($pathOrOptions, $value = '')
152
+	{
153
+		if (is_string($pathOrOptions)) {
154
+			$pathOrOptions = glsr(Helper::class)->dataSet($this->all(), $pathOrOptions, $value);
155
+		}
156
+		if ($result = update_option(static::databaseKey(), (array) $pathOrOptions)) {
157
+			$this->reset();
158
+		}
159
+		return $result;
160
+	}
161 161
 }
Please login to merge, or discard this 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 2 patches
Indentation   +103 added lines, -103 removed lines patch added patch discarded remove patch
@@ -7,23 +7,23 @@  discard block
 block discarded – undo
7 7
 
8 8
 class SqlQueries
9 9
 {
10
-    protected $db;
11
-    protected $postType;
10
+	protected $db;
11
+	protected $postType;
12 12
 
13
-    public function __construct()
14
-    {
15
-        global $wpdb;
16
-        $this->db = $wpdb;
17
-        $this->postType = Application::POST_TYPE;
18
-    }
13
+	public function __construct()
14
+	{
15
+		global $wpdb;
16
+		$this->db = $wpdb;
17
+		$this->postType = Application::POST_TYPE;
18
+	}
19 19
 
20
-    /**
21
-     * @param string $metaReviewId
22
-     * @return int
23
-     */
24
-    public function getPostIdFromReviewId($metaReviewId)
25
-    {
26
-        $postId = $this->db->get_var("
20
+	/**
21
+	 * @param string $metaReviewId
22
+	 * @return int
23
+	 */
24
+	public function getPostIdFromReviewId($metaReviewId)
25
+	{
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
@@ -31,17 +31,17 @@  discard block
 block discarded – undo
31 31
             AND m.meta_key = '_review_id'
32 32
             AND m.meta_value = '{$metaReviewId}'
33 33
         ");
34
-        return intval($postId);
35
-    }
34
+		return intval($postId);
35
+	}
36 36
 
37
-    /**
38
-     * @param int $lastPostId
39
-     * @param int $limit
40
-     * @return array
41
-     */
42
-    public function getReviewCounts(array $args, $lastPostId = 0, $limit = 500)
43
-    {
44
-        return (array) $this->db->get_results("
37
+	/**
38
+	 * @param int $lastPostId
39
+	 * @param int $limit
40
+	 * @return array
41
+	 */
42
+	public function getReviewCounts(array $args, $lastPostId = 0, $limit = 500)
43
+	{
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
@@ -56,17 +56,17 @@  discard block
 block discarded – undo
56 56
             ORDER By p.ID ASC
57 57
             LIMIT {$limit}
58 58
         ");
59
-    }
59
+	}
60 60
 
61
-    /**
62
-     * @todo remove this?
63
-     * @param string $metaKey
64
-     * @return array
65
-     */
66
-    public function getReviewCountsFor($metaKey)
67
-    {
68
-        $metaKey = glsr(Helper::class)->prefix('_', $metaKey);
69
-        return (array) $this->db->get_results("
61
+	/**
62
+	 * @todo remove this?
63
+	 * @param string $metaKey
64
+	 * @return array
65
+	 */
66
+	public function getReviewCountsFor($metaKey)
67
+	{
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
@@ -74,16 +74,16 @@  discard block
 block discarded – undo
74 74
             AND m.meta_key = '{$metaKey}'
75 75
             GROUP BY name
76 76
         ");
77
-    }
77
+	}
78 78
 
79
-    /**
80
-     * @todo remove this?
81
-     * @param string $reviewType
82
-     * @return array
83
-     */
84
-    public function getReviewIdsByType($reviewType)
85
-    {
86
-        $results = $this->db->get_col("
79
+	/**
80
+	 * @todo remove this?
81
+	 * @param string $reviewType
82
+	 * @return array
83
+	 */
84
+	public function getReviewIdsByType($reviewType)
85
+	{
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
@@ -93,20 +93,20 @@  discard block
 block discarded – undo
93 93
             AND m2.meta_key = '_review_type'
94 94
             AND m2.meta_value = '{$reviewType}'
95 95
         ");
96
-        return array_keys(array_flip($results));
97
-    }
96
+		return array_keys(array_flip($results));
97
+	}
98 98
 
99
-    /**
100
-     * @param int $greaterThanId
101
-     * @param int $limit
102
-     * @return array
103
-     */
104
-    public function getReviewRatingsFromIds(array $postIds, $greaterThanId = 0, $limit = 100)
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("
99
+	/**
100
+	 * @param int $greaterThanId
101
+	 * @param int $limit
102
+	 * @return array
103
+	 */
104
+	public function getReviewRatingsFromIds(array $postIds, $greaterThanId = 0, $limit = 100)
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("
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
@@ -119,17 +119,17 @@  discard block
 block discarded – undo
119 119
             ORDER By p.ID ASC
120 120
             LIMIT {$limit}
121 121
         ");
122
-    }
122
+	}
123 123
 
124
-    /**
125
-     * @param string $key
126
-     * @param string $status
127
-     * @return array
128
-     */
129
-    public function getReviewsMeta($key, $status = 'publish')
130
-    {
131
-        $key = glsr(Helper::class)->prefix('_', $key);
132
-        $values = $this->db->get_col("
124
+	/**
125
+	 * @param string $key
126
+	 * @param string $status
127
+	 * @return array
128
+	 */
129
+	public function getReviewsMeta($key, $status = 'publish')
130
+	{
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
@@ -140,42 +140,42 @@  discard block
 block discarded – undo
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 142
         ");
143
-        sort($values);
144
-        return $values;
145
-    }
143
+		sort($values);
144
+		return $values;
145
+	}
146 146
 
147
-    /**
148
-     * @param string $and
149
-     * @return string
150
-     */
151
-    protected function getAndForCounts(array $args, $and = '')
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']}' ";
157
-        }
158
-        if ($postIds) {
159
-            $and.= "AND m3.meta_key = '_assigned_to' AND m3.meta_value IN ({$postIds}) ";
160
-        }
161
-        if ($termIds) {
162
-            $and.= "AND tr.term_taxonomy_id IN ({$termIds}) ";
163
-        }
164
-        return apply_filters('site-reviews/query/and-for-counts', $and);
165
-    }
147
+	/**
148
+	 * @param string $and
149
+	 * @return string
150
+	 */
151
+	protected function getAndForCounts(array $args, $and = '')
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']}' ";
157
+		}
158
+		if ($postIds) {
159
+			$and.= "AND m3.meta_key = '_assigned_to' AND m3.meta_value IN ({$postIds}) ";
160
+		}
161
+		if ($termIds) {
162
+			$and.= "AND tr.term_taxonomy_id IN ({$termIds}) ";
163
+		}
164
+		return apply_filters('site-reviews/query/and-for-counts', $and);
165
+	}
166 166
 
167
-    /**
168
-     * @param string $innerJoin
169
-     * @return string
170
-     */
171
-    protected function getInnerJoinForCounts(array $args, $innerJoin = '')
172
-    {
173
-        if (!empty(glsr_get($args, 'post_ids'))) {
174
-            $innerJoin.= "INNER JOIN {$this->db->postmeta} AS m3 ON p.ID = m3.post_id ";
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 ";
178
-        }
179
-        return apply_filters('site-reviews/query/inner-join-for-counts', $innerJoin);
180
-    }
167
+	/**
168
+	 * @param string $innerJoin
169
+	 * @return string
170
+	 */
171
+	protected function getInnerJoinForCounts(array $args, $innerJoin = '')
172
+	{
173
+		if (!empty(glsr_get($args, 'post_ids'))) {
174
+			$innerJoin.= "INNER JOIN {$this->db->postmeta} AS m3 ON p.ID = m3.post_id ";
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 ";
178
+		}
179
+		return apply_filters('site-reviews/query/inner-join-for-counts', $innerJoin);
180
+	}
181 181
 }
Please login to merge, or discard this 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/Upgrade_4_0_0.php 2 patches
Indentation   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -9,59 +9,59 @@
 block discarded – undo
9 9
 
10 10
 class Upgrade_4_0_0
11 11
 {
12
-    public function __construct()
13
-    {
14
-        $this->migrateSettings();
15
-        $this->protectMetaKeys();
16
-        $this->deleteSessions();
17
-        delete_transient(Application::ID.'_cloudflare_ips');
18
-    }
12
+	public function __construct()
13
+	{
14
+		$this->migrateSettings();
15
+		$this->protectMetaKeys();
16
+		$this->deleteSessions();
17
+		delete_transient(Application::ID.'_cloudflare_ips');
18
+	}
19 19
 
20
-    /**
21
-     * @return void
22
-     */
23
-    public function deleteSessions()
24
-    {
25
-        global $wpdb;
26
-        $wpdb->query("
20
+	/**
21
+	 * @return void
22
+	 */
23
+	public function deleteSessions()
24
+	{
25
+		global $wpdb;
26
+		$wpdb->query("
27 27
             DELETE
28 28
             FROM {$wpdb->options}
29 29
             WHERE option_name LIKE '_glsr_session%'
30 30
         ");
31
-    }
31
+	}
32 32
 
33
-    /**
34
-     * @return void
35
-     */
36
-    public function migrateSettings()
37
-    {
38
-        if ($settings = get_option(OptionManager::databaseKey(3))) {
39
-            $previousVersion = glsr(Helper::class)->dataGet($settings, 'version', '0.0.0');
40
-            $multilingual = 'yes' == glsr(Helper::class)->dataGet($settings, 'settings.general.support.polylang')
41
-                ? 'polylang'
42
-                : '';
43
-            $settings = glsr(Helper::class)->dataSet($settings, 'settings.general.multilingual', $multilingual);
44
-            $settings = glsr(Helper::class)->dataSet($settings, 'settings.submissions.blacklist.integration', '');
45
-            unset($settings['settings']['general']['support']);
46
-            update_option(OptionManager::databaseKey(4), $settings);
47
-        }
48
-    }
33
+	/**
34
+	 * @return void
35
+	 */
36
+	public function migrateSettings()
37
+	{
38
+		if ($settings = get_option(OptionManager::databaseKey(3))) {
39
+			$previousVersion = glsr(Helper::class)->dataGet($settings, 'version', '0.0.0');
40
+			$multilingual = 'yes' == glsr(Helper::class)->dataGet($settings, 'settings.general.support.polylang')
41
+				? 'polylang'
42
+				: '';
43
+			$settings = glsr(Helper::class)->dataSet($settings, 'settings.general.multilingual', $multilingual);
44
+			$settings = glsr(Helper::class)->dataSet($settings, 'settings.submissions.blacklist.integration', '');
45
+			unset($settings['settings']['general']['support']);
46
+			update_option(OptionManager::databaseKey(4), $settings);
47
+		}
48
+	}
49 49
 
50
-    /**
51
-     * @return void
52
-     */
53
-    public function protectMetaKeys()
54
-    {
55
-        global $wpdb;
56
-        $keys = array_keys(glsr(CreateReviewDefaults::class)->defaults());
57
-        $keys = implode("','", $keys);
58
-        $postType = Application::POST_TYPE;
59
-        $wpdb->query("
50
+	/**
51
+	 * @return void
52
+	 */
53
+	public function protectMetaKeys()
54
+	{
55
+		global $wpdb;
56
+		$keys = array_keys(glsr(CreateReviewDefaults::class)->defaults());
57
+		$keys = implode("','", $keys);
58
+		$postType = Application::POST_TYPE;
59
+		$wpdb->query("
60 60
             UPDATE {$wpdb->postmeta} pm
61 61
             INNER JOIN {$wpdb->posts} p ON p.id = pm.post_id
62 62
             SET pm.meta_key = CONCAT('_', pm.meta_key)
63 63
             WHERE pm.meta_key IN ('{$keys}')
64 64
             AND p.post_type = '{$postType}'
65 65
         ");
66
-    }
66
+	}
67 67
 }
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
         $this->migrateSettings();
15 15
         $this->protectMetaKeys();
16 16
         $this->deleteSessions();
17
-        delete_transient(Application::ID.'_cloudflare_ips');
17
+        delete_transient( Application::ID.'_cloudflare_ips' );
18 18
     }
19 19
 
20 20
     /**
@@ -23,11 +23,11 @@  discard block
 block discarded – undo
23 23
     public function deleteSessions()
24 24
     {
25 25
         global $wpdb;
26
-        $wpdb->query("
26
+        $wpdb->query( "
27 27
             DELETE
28 28
             FROM {$wpdb->options}
29 29
             WHERE option_name LIKE '_glsr_session%'
30
-        ");
30
+        " );
31 31
     }
32 32
 
33 33
     /**
@@ -35,15 +35,15 @@  discard block
 block discarded – undo
35 35
      */
36 36
     public function migrateSettings()
37 37
     {
38
-        if ($settings = get_option(OptionManager::databaseKey(3))) {
39
-            $previousVersion = glsr(Helper::class)->dataGet($settings, 'version', '0.0.0');
40
-            $multilingual = 'yes' == glsr(Helper::class)->dataGet($settings, 'settings.general.support.polylang')
38
+        if( $settings = get_option( OptionManager::databaseKey( 3 ) ) ) {
39
+            $previousVersion = glsr( Helper::class )->dataGet( $settings, 'version', '0.0.0' );
40
+            $multilingual = 'yes' == glsr( Helper::class )->dataGet( $settings, 'settings.general.support.polylang' )
41 41
                 ? 'polylang'
42 42
                 : '';
43
-            $settings = glsr(Helper::class)->dataSet($settings, 'settings.general.multilingual', $multilingual);
44
-            $settings = glsr(Helper::class)->dataSet($settings, 'settings.submissions.blacklist.integration', '');
43
+            $settings = glsr( Helper::class )->dataSet( $settings, 'settings.general.multilingual', $multilingual );
44
+            $settings = glsr( Helper::class )->dataSet( $settings, 'settings.submissions.blacklist.integration', '' );
45 45
             unset($settings['settings']['general']['support']);
46
-            update_option(OptionManager::databaseKey(4), $settings);
46
+            update_option( OptionManager::databaseKey( 4 ), $settings );
47 47
         }
48 48
     }
49 49
 
@@ -53,15 +53,15 @@  discard block
 block discarded – undo
53 53
     public function protectMetaKeys()
54 54
     {
55 55
         global $wpdb;
56
-        $keys = array_keys(glsr(CreateReviewDefaults::class)->defaults());
57
-        $keys = implode("','", $keys);
56
+        $keys = array_keys( glsr( CreateReviewDefaults::class )->defaults() );
57
+        $keys = implode( "','", $keys );
58 58
         $postType = Application::POST_TYPE;
59
-        $wpdb->query("
59
+        $wpdb->query( "
60 60
             UPDATE {$wpdb->postmeta} pm
61 61
             INNER JOIN {$wpdb->posts} p ON p.id = pm.post_id
62 62
             SET pm.meta_key = CONCAT('_', pm.meta_key)
63 63
             WHERE pm.meta_key IN ('{$keys}')
64 64
             AND p.post_type = '{$postType}'
65
-        ");
65
+        " );
66 66
     }
67 67
 }
Please login to merge, or discard this patch.
plugin/Modules/Wpml.php 2 patches
Indentation   +73 added lines, -73 removed lines patch added patch discarded remove patch
@@ -7,83 +7,83 @@
 block discarded – undo
7 7
 
8 8
 class Wpml implements Contract
9 9
 {
10
-    const PLUGIN_NAME = 'WPML';
11
-    const SUPPORTED_VERSION = '3.3.5';
10
+	const PLUGIN_NAME = 'WPML';
11
+	const SUPPORTED_VERSION = '3.3.5';
12 12
 
13
-    /**
14
-     * {@inheritdoc}
15
-     */
16
-    public function getPost($postId)
17
-    {
18
-        $postId = trim($postId);
19
-        if (!is_numeric($postId)) {
20
-            return;
21
-        }
22
-        if ($this->isEnabled()) {
23
-            $postId = apply_filters('wpml_object_id', $postId, 'any', true);
24
-        }
25
-        return get_post(intval($postId));
26
-    }
13
+	/**
14
+	 * {@inheritdoc}
15
+	 */
16
+	public function getPost($postId)
17
+	{
18
+		$postId = trim($postId);
19
+		if (!is_numeric($postId)) {
20
+			return;
21
+		}
22
+		if ($this->isEnabled()) {
23
+			$postId = apply_filters('wpml_object_id', $postId, 'any', true);
24
+		}
25
+		return get_post(intval($postId));
26
+	}
27 27
 
28
-    /**
29
-     * {@inheritdoc}
30
-     */
31
-    public function getPostIds(array $postIds)
32
-    {
33
-        if (!$this->isEnabled()) {
34
-            return $postIds;
35
-        }
36
-        $newPostIds = [];
37
-        foreach ($this->cleanIds($postIds) as $postId) {
38
-            $postType = get_post_type($postId);
39
-            if (!$postType) {
40
-                continue;
41
-            }
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)) {
46
-                $translations = [];
47
-            }
48
-            $newPostIds = array_merge(
49
-                $newPostIds,
50
-                array_column($translations, 'element_id')
51
-            );
52
-        }
53
-        return $this->cleanIds($newPostIds);
54
-    }
28
+	/**
29
+	 * {@inheritdoc}
30
+	 */
31
+	public function getPostIds(array $postIds)
32
+	{
33
+		if (!$this->isEnabled()) {
34
+			return $postIds;
35
+		}
36
+		$newPostIds = [];
37
+		foreach ($this->cleanIds($postIds) as $postId) {
38
+			$postType = get_post_type($postId);
39
+			if (!$postType) {
40
+				continue;
41
+			}
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)) {
46
+				$translations = [];
47
+			}
48
+			$newPostIds = array_merge(
49
+				$newPostIds,
50
+				array_column($translations, 'element_id')
51
+			);
52
+		}
53
+		return $this->cleanIds($newPostIds);
54
+	}
55 55
 
56
-    /**
57
-     * {@inheritdoc}
58
-     */
59
-    public function isActive()
60
-    {
61
-        return defined('ICL_SITEPRESS_VERSION');
62
-    }
56
+	/**
57
+	 * {@inheritdoc}
58
+	 */
59
+	public function isActive()
60
+	{
61
+		return defined('ICL_SITEPRESS_VERSION');
62
+	}
63 63
 
64
-    /**
65
-     * {@inheritdoc}
66
-     */
67
-    public function isEnabled()
68
-    {
69
-        return $this->isActive()
70
-            && 'wpml' == glsr(OptionManager::class)->get('settings.general.multilingual');
71
-    }
64
+	/**
65
+	 * {@inheritdoc}
66
+	 */
67
+	public function isEnabled()
68
+	{
69
+		return $this->isActive()
70
+			&& 'wpml' == glsr(OptionManager::class)->get('settings.general.multilingual');
71
+	}
72 72
 
73
-    /**
74
-     * {@inheritdoc}
75
-     */
76
-    public function isSupported()
77
-    {
78
-        return $this->isActive()
79
-            && version_compare(ICL_SITEPRESS_VERSION, static::SUPPORTED_VERSION, '>=');
80
-    }
73
+	/**
74
+	 * {@inheritdoc}
75
+	 */
76
+	public function isSupported()
77
+	{
78
+		return $this->isActive()
79
+			&& version_compare(ICL_SITEPRESS_VERSION, static::SUPPORTED_VERSION, '>=');
80
+	}
81 81
 
82
-    /**
83
-     * @return array
84
-     */
85
-    protected function cleanIds(array $postIds)
86
-    {
87
-        return array_filter(array_unique($postIds));
88
-    }
82
+	/**
83
+	 * @return array
84
+	 */
85
+	protected function cleanIds(array $postIds)
86
+	{
87
+		return array_filter(array_unique($postIds));
88
+	}
89 89
 }
Please login to merge, or discard this 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 2 patches
Indentation   +69 added lines, -69 removed lines patch added patch discarded remove patch
@@ -7,79 +7,79 @@
 block discarded – undo
7 7
 
8 8
 class Polylang implements Contract
9 9
 {
10
-    const PLUGIN_NAME = 'Polylang';
11
-    const SUPPORTED_VERSION = '2.3';
10
+	const PLUGIN_NAME = 'Polylang';
11
+	const SUPPORTED_VERSION = '2.3';
12 12
 
13
-    /**
14
-     * {@inheritdoc}
15
-     */
16
-    public function getPost($postId)
17
-    {
18
-        $postId = trim($postId);
19
-        if (!is_numeric($postId)) {
20
-            return;
21
-        }
22
-        if ($this->isEnabled()) {
23
-            $polylangPostId = pll_get_post($postId, pll_get_post_language(get_the_ID()));
24
-        }
25
-        if (!empty($polylangPostId)) {
26
-            $postId = $polylangPostId;
27
-        }
28
-        return get_post(intval($postId));
29
-    }
13
+	/**
14
+	 * {@inheritdoc}
15
+	 */
16
+	public function getPost($postId)
17
+	{
18
+		$postId = trim($postId);
19
+		if (!is_numeric($postId)) {
20
+			return;
21
+		}
22
+		if ($this->isEnabled()) {
23
+			$polylangPostId = pll_get_post($postId, pll_get_post_language(get_the_ID()));
24
+		}
25
+		if (!empty($polylangPostId)) {
26
+			$postId = $polylangPostId;
27
+		}
28
+		return get_post(intval($postId));
29
+	}
30 30
 
31
-    /**
32
-     * {@inheritdoc}
33
-     */
34
-    public function getPostIds(array $postIds)
35
-    {
36
-        if (!$this->isEnabled()) {
37
-            return $postIds;
38
-        }
39
-        $newPostIds = [];
40
-        foreach ($this->cleanIds($postIds) as $postId) {
41
-            $newPostIds = array_merge(
42
-                $newPostIds,
43
-                array_values(pll_get_post_translations($postId))
44
-            );
45
-        }
46
-        return $this->cleanIds($newPostIds);
47
-    }
31
+	/**
32
+	 * {@inheritdoc}
33
+	 */
34
+	public function getPostIds(array $postIds)
35
+	{
36
+		if (!$this->isEnabled()) {
37
+			return $postIds;
38
+		}
39
+		$newPostIds = [];
40
+		foreach ($this->cleanIds($postIds) as $postId) {
41
+			$newPostIds = array_merge(
42
+				$newPostIds,
43
+				array_values(pll_get_post_translations($postId))
44
+			);
45
+		}
46
+		return $this->cleanIds($newPostIds);
47
+	}
48 48
 
49
-    /**
50
-     * {@inheritdoc}
51
-     */
52
-    public function isActive()
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');
58
-    }
49
+	/**
50
+	 * {@inheritdoc}
51
+	 */
52
+	public function isActive()
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');
58
+	}
59 59
 
60
-    /**
61
-     * {@inheritdoc}
62
-     */
63
-    public function isEnabled()
64
-    {
65
-        return $this->isActive()
66
-            && 'polylang' == glsr(OptionManager::class)->get('settings.general.multilingual');
67
-    }
60
+	/**
61
+	 * {@inheritdoc}
62
+	 */
63
+	public function isEnabled()
64
+	{
65
+		return $this->isActive()
66
+			&& 'polylang' == glsr(OptionManager::class)->get('settings.general.multilingual');
67
+	}
68 68
 
69
-    /**
70
-     * {@inheritdoc}
71
-     */
72
-    public function isSupported()
73
-    {
74
-        return defined('POLYLANG_VERSION')
75
-            && version_compare(POLYLANG_VERSION, static::SUPPORTED_VERSION, '>=');
76
-    }
69
+	/**
70
+	 * {@inheritdoc}
71
+	 */
72
+	public function isSupported()
73
+	{
74
+		return defined('POLYLANG_VERSION')
75
+			&& version_compare(POLYLANG_VERSION, static::SUPPORTED_VERSION, '>=');
76
+	}
77 77
 
78
-    /**
79
-     * @return array
80
-     */
81
-    protected function cleanIds(array $postIds)
82
-    {
83
-        return array_filter(array_unique($postIds));
84
-    }
78
+	/**
79
+	 * @return array
80
+	 */
81
+	protected function cleanIds(array $postIds)
82
+	{
83
+		return array_filter(array_unique($postIds));
84
+	}
85 85
 }
Please login to merge, or discard this 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 2 patches
Indentation   +190 added lines, -190 removed lines patch added patch discarded remove patch
@@ -4,206 +4,206 @@
 block discarded – undo
4 4
 
5 5
 class Rating
6 6
 {
7
-    /**
8
-     * The more sure we are of the confidence interval (the higher the confidence level), the less
9
-     * precise the estimation will be as the margin for error will be higher.
10
-     * @see http://homepages.math.uic.edu/~bpower6/stat101/Confidence%20Intervals.pdf
11
-     * @see https://www.thecalculator.co/math/Confidence-Interval-Calculator-210.html
12
-     * @see https://www.youtube.com/watch?v=grodoLzThy4
13
-     * @see https://en.wikipedia.org/wiki/Standard_score
14
-     * @var array
15
-     */
16
-    const CONFIDENCE_LEVEL_Z_SCORES = [
17
-        50 => 0.67449,
18
-        70 => 1.04,
19
-        75 => 1.15035,
20
-        80 => 1.282,
21
-        85 => 1.44,
22
-        90 => 1.64485,
23
-        92 => 1.75,
24
-        95 => 1.95996,
25
-        96 => 2.05,
26
-        97 => 2.17009,
27
-        98 => 2.326,
28
-        99 => 2.57583,
29
-        '99.5' => 2.81,
30
-        '99.8' => 3.08,
31
-        '99.9' => 3.29053,
32
-    ];
7
+	/**
8
+	 * The more sure we are of the confidence interval (the higher the confidence level), the less
9
+	 * precise the estimation will be as the margin for error will be higher.
10
+	 * @see http://homepages.math.uic.edu/~bpower6/stat101/Confidence%20Intervals.pdf
11
+	 * @see https://www.thecalculator.co/math/Confidence-Interval-Calculator-210.html
12
+	 * @see https://www.youtube.com/watch?v=grodoLzThy4
13
+	 * @see https://en.wikipedia.org/wiki/Standard_score
14
+	 * @var array
15
+	 */
16
+	const CONFIDENCE_LEVEL_Z_SCORES = [
17
+		50 => 0.67449,
18
+		70 => 1.04,
19
+		75 => 1.15035,
20
+		80 => 1.282,
21
+		85 => 1.44,
22
+		90 => 1.64485,
23
+		92 => 1.75,
24
+		95 => 1.95996,
25
+		96 => 2.05,
26
+		97 => 2.17009,
27
+		98 => 2.326,
28
+		99 => 2.57583,
29
+		'99.5' => 2.81,
30
+		'99.8' => 3.08,
31
+		'99.9' => 3.29053,
32
+	];
33 33
 
34
-    /**
35
-     * @var int
36
-     */
37
-    const MAX_RATING = 5;
34
+	/**
35
+	 * @var int
36
+	 */
37
+	const MAX_RATING = 5;
38 38
 
39
-    /**
40
-     * @var int
41
-     */
42
-    const MIN_RATING = 1;
39
+	/**
40
+	 * @var int
41
+	 */
42
+	const MIN_RATING = 1;
43 43
 
44
-    /**
45
-     * @param int $roundBy
46
-     * @return float
47
-     */
48
-    public function getAverage(array $ratingCounts, $roundBy = 1)
49
-    {
50
-        $average = array_sum($ratingCounts);
51
-        if ($average > 0) {
52
-            $average = round($this->getTotalSum($ratingCounts) / $average, intval($roundBy));
53
-        }
54
-        return floatval(apply_filters('site-reviews/rating/average', $average, $ratingCounts));
55
-    }
44
+	/**
45
+	 * @param int $roundBy
46
+	 * @return float
47
+	 */
48
+	public function getAverage(array $ratingCounts, $roundBy = 1)
49
+	{
50
+		$average = array_sum($ratingCounts);
51
+		if ($average > 0) {
52
+			$average = round($this->getTotalSum($ratingCounts) / $average, intval($roundBy));
53
+		}
54
+		return floatval(apply_filters('site-reviews/rating/average', $average, $ratingCounts));
55
+	}
56 56
 
57
-    /**
58
-     * Get the lower bound for up/down ratings
59
-     * Method receives an up/down ratings array: [1, -1, -1, 1, 1, -1].
60
-     * @see http://www.evanmiller.org/how-not-to-sort-by-average-rating.html
61
-     * @see https://news.ycombinator.com/item?id=10481507
62
-     * @see https://dataorigami.net/blogs/napkin-folding/79030467-an-algorithm-to-sort-top-comments
63
-     * @see http://julesjacobs.github.io/2015/08/17/bayesian-scoring-of-ratings.html
64
-     * @param int $confidencePercentage
65
-     * @return int|float
66
-     */
67
-    public function getLowerBound(array $upDownCounts = [0, 0], $confidencePercentage = 95)
68
-    {
69
-        $numRatings = array_sum($upDownCounts);
70
-        if ($numRatings < 1) {
71
-            return 0;
72
-        }
73
-        $z = static::CONFIDENCE_LEVEL_Z_SCORES[$confidencePercentage];
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);
76
-    }
57
+	/**
58
+	 * Get the lower bound for up/down ratings
59
+	 * Method receives an up/down ratings array: [1, -1, -1, 1, 1, -1].
60
+	 * @see http://www.evanmiller.org/how-not-to-sort-by-average-rating.html
61
+	 * @see https://news.ycombinator.com/item?id=10481507
62
+	 * @see https://dataorigami.net/blogs/napkin-folding/79030467-an-algorithm-to-sort-top-comments
63
+	 * @see http://julesjacobs.github.io/2015/08/17/bayesian-scoring-of-ratings.html
64
+	 * @param int $confidencePercentage
65
+	 * @return int|float
66
+	 */
67
+	public function getLowerBound(array $upDownCounts = [0, 0], $confidencePercentage = 95)
68
+	{
69
+		$numRatings = array_sum($upDownCounts);
70
+		if ($numRatings < 1) {
71
+			return 0;
72
+		}
73
+		$z = static::CONFIDENCE_LEVEL_Z_SCORES[$confidencePercentage];
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);
76
+	}
77 77
 
78
-    /**
79
-     * @return int|float
80
-     */
81
-    public function getOverallPercentage(array $ratingCounts)
82
-    {
83
-        return round($this->getAverage($ratingCounts) * 100 / glsr()->constant('MAX_RATING', __CLASS__), 2);
84
-    }
78
+	/**
79
+	 * @return int|float
80
+	 */
81
+	public function getOverallPercentage(array $ratingCounts)
82
+	{
83
+		return round($this->getAverage($ratingCounts) * 100 / glsr()->constant('MAX_RATING', __CLASS__), 2);
84
+	}
85 85
 
86
-    /**
87
-     * @return array
88
-     */
89
-    public function getPercentages(array $ratingCounts)
90
-    {
91
-        $total = array_sum($ratingCounts);
92
-        foreach ($ratingCounts as $index => $count) {
93
-            if (empty($count)) {
94
-                continue;
95
-            }
96
-            $ratingCounts[$index] = $count / $total * 100;
97
-        }
98
-        return $this->getRoundedPercentages($ratingCounts);
99
-    }
86
+	/**
87
+	 * @return array
88
+	 */
89
+	public function getPercentages(array $ratingCounts)
90
+	{
91
+		$total = array_sum($ratingCounts);
92
+		foreach ($ratingCounts as $index => $count) {
93
+			if (empty($count)) {
94
+				continue;
95
+			}
96
+			$ratingCounts[$index] = $count / $total * 100;
97
+		}
98
+		return $this->getRoundedPercentages($ratingCounts);
99
+	}
100 100
 
101
-    /**
102
-     * @return float
103
-     */
104
-    public function getRanking(array $ratingCounts)
105
-    {
106
-        return floatval(apply_filters('site-reviews/rating/ranking',
107
-            $this->getRankingUsingImdb($ratingCounts),
108
-            $ratingCounts,
109
-            $this
110
-        ));
111
-    }
101
+	/**
102
+	 * @return float
103
+	 */
104
+	public function getRanking(array $ratingCounts)
105
+	{
106
+		return floatval(apply_filters('site-reviews/rating/ranking',
107
+			$this->getRankingUsingImdb($ratingCounts),
108
+			$ratingCounts,
109
+			$this
110
+		));
111
+	}
112 112
 
113
-    /**
114
-     * Get the bayesian ranking for an array of reviews
115
-     * This formula is the same one used by IMDB to rank their top 250 films.
116
-     * @see https://www.xkcd.com/937/
117
-     * @see https://districtdatalabs.silvrback.com/computing-a-bayesian-estimate-of-star-rating-means
118
-     * @see http://fulmicoton.com/posts/bayesian_rating/
119
-     * @see https://stats.stackexchange.com/questions/93974/is-there-an-equivalent-to-lower-bound-of-wilson-score-confidence-interval-for-va
120
-     * @param int $confidencePercentage
121
-     * @return int|float
122
-     */
123
-    public function getRankingUsingImdb(array $ratingCounts, $confidencePercentage = 70)
124
-    {
125
-        $avgRating = $this->getAverage($ratingCounts);
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
-        // 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
129
-        // Represents the number of ratings expected to begin observing a pattern that would put confidence in the prior.
130
-        $bayesMinimal = 10; // confidence
131
-        $numOfReviews = array_sum($ratingCounts);
132
-        return $avgRating > 0
133
-            ? (($bayesMinimal * $bayesMean) + ($avgRating * $numOfReviews)) / ($bayesMinimal + $numOfReviews)
134
-            : 0;
135
-    }
113
+	/**
114
+	 * Get the bayesian ranking for an array of reviews
115
+	 * This formula is the same one used by IMDB to rank their top 250 films.
116
+	 * @see https://www.xkcd.com/937/
117
+	 * @see https://districtdatalabs.silvrback.com/computing-a-bayesian-estimate-of-star-rating-means
118
+	 * @see http://fulmicoton.com/posts/bayesian_rating/
119
+	 * @see https://stats.stackexchange.com/questions/93974/is-there-an-equivalent-to-lower-bound-of-wilson-score-confidence-interval-for-va
120
+	 * @param int $confidencePercentage
121
+	 * @return int|float
122
+	 */
123
+	public function getRankingUsingImdb(array $ratingCounts, $confidencePercentage = 70)
124
+	{
125
+		$avgRating = $this->getAverage($ratingCounts);
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
+		// 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
129
+		// Represents the number of ratings expected to begin observing a pattern that would put confidence in the prior.
130
+		$bayesMinimal = 10; // confidence
131
+		$numOfReviews = array_sum($ratingCounts);
132
+		return $avgRating > 0
133
+			? (($bayesMinimal * $bayesMean) + ($avgRating * $numOfReviews)) / ($bayesMinimal + $numOfReviews)
134
+			: 0;
135
+	}
136 136
 
137
-    /**
138
-     * The quality of a 5 star rating depends not only on the average number of stars but also on
139
-     * the number of reviews. This method calculates the bayesian ranking of a page by its number
140
-     * of reviews and their rating.
141
-     * @see http://www.evanmiller.org/ranking-items-with-star-ratings.html
142
-     * @see https://stackoverflow.com/questions/1411199/what-is-a-better-way-to-sort-by-a-5-star-rating/1411268
143
-     * @see http://julesjacobs.github.io/2015/08/17/bayesian-scoring-of-ratings.html
144
-     * @param int $confidencePercentage
145
-     * @return float
146
-     */
147
-    public function getRankingUsingZScores(array $ratingCounts, $confidencePercentage = 90)
148
-    {
149
-        $ratingCountsSum = array_sum($ratingCounts) + glsr()->constant('MAX_RATING', __CLASS__);
150
-        $weight = $this->getWeight($ratingCounts, $ratingCountsSum);
151
-        $weightPow2 = $this->getWeight($ratingCounts, $ratingCountsSum, true);
152
-        $zScore = static::CONFIDENCE_LEVEL_Z_SCORES[$confidencePercentage];
153
-        return $weight - $zScore * sqrt(($weightPow2 - pow($weight, 2)) / ($ratingCountsSum + 1));
154
-    }
137
+	/**
138
+	 * The quality of a 5 star rating depends not only on the average number of stars but also on
139
+	 * the number of reviews. This method calculates the bayesian ranking of a page by its number
140
+	 * of reviews and their rating.
141
+	 * @see http://www.evanmiller.org/ranking-items-with-star-ratings.html
142
+	 * @see https://stackoverflow.com/questions/1411199/what-is-a-better-way-to-sort-by-a-5-star-rating/1411268
143
+	 * @see http://julesjacobs.github.io/2015/08/17/bayesian-scoring-of-ratings.html
144
+	 * @param int $confidencePercentage
145
+	 * @return float
146
+	 */
147
+	public function getRankingUsingZScores(array $ratingCounts, $confidencePercentage = 90)
148
+	{
149
+		$ratingCountsSum = array_sum($ratingCounts) + glsr()->constant('MAX_RATING', __CLASS__);
150
+		$weight = $this->getWeight($ratingCounts, $ratingCountsSum);
151
+		$weightPow2 = $this->getWeight($ratingCounts, $ratingCountsSum, true);
152
+		$zScore = static::CONFIDENCE_LEVEL_Z_SCORES[$confidencePercentage];
153
+		return $weight - $zScore * sqrt(($weightPow2 - pow($weight, 2)) / ($ratingCountsSum + 1));
154
+	}
155 155
 
156
-    /**
157
-     * @param int $target
158
-     * @return array
159
-     */
160
-    protected function getRoundedPercentages(array $percentages, $totalPercent = 100)
161
-    {
162
-        array_walk($percentages, function (&$percent, $index) {
163
-            $percent = [
164
-                'index' => $index,
165
-                'percent' => floor($percent),
166
-                'remainder' => fmod($percent, 1),
167
-            ];
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);
172
-        $i = 0;
173
-        if (array_sum(glsr_array_column($percentages, 'percent')) > 0) {
174
-            while (array_sum(glsr_array_column($percentages, 'percent')) < $totalPercent) {
175
-                ++$percentages[$i]['percent'];
176
-                ++$i;
177
-            }
178
-        }
179
-        array_multisort($indexes, SORT_DESC, $percentages);
180
-        return array_combine($indexes, glsr_array_column($percentages, 'percent'));
181
-    }
156
+	/**
157
+	 * @param int $target
158
+	 * @return array
159
+	 */
160
+	protected function getRoundedPercentages(array $percentages, $totalPercent = 100)
161
+	{
162
+		array_walk($percentages, function (&$percent, $index) {
163
+			$percent = [
164
+				'index' => $index,
165
+				'percent' => floor($percent),
166
+				'remainder' => fmod($percent, 1),
167
+			];
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);
172
+		$i = 0;
173
+		if (array_sum(glsr_array_column($percentages, 'percent')) > 0) {
174
+			while (array_sum(glsr_array_column($percentages, 'percent')) < $totalPercent) {
175
+				++$percentages[$i]['percent'];
176
+				++$i;
177
+			}
178
+		}
179
+		array_multisort($indexes, SORT_DESC, $percentages);
180
+		return array_combine($indexes, glsr_array_column($percentages, 'percent'));
181
+	}
182 182
 
183
-    /**
184
-     * @return int
185
-     */
186
-    protected function getTotalSum(array $ratingCounts)
187
-    {
188
-        return array_reduce(array_keys($ratingCounts), function ($carry, $index) use ($ratingCounts) {
189
-            return $carry + ($index * $ratingCounts[$index]);
190
-        });
191
-    }
183
+	/**
184
+	 * @return int
185
+	 */
186
+	protected function getTotalSum(array $ratingCounts)
187
+	{
188
+		return array_reduce(array_keys($ratingCounts), function ($carry, $index) use ($ratingCounts) {
189
+			return $carry + ($index * $ratingCounts[$index]);
190
+		});
191
+	}
192 192
 
193
-    /**
194
-     * @param int|float $ratingCountsSum
195
-     * @param bool $powerOf2
196
-     * @return float
197
-     */
198
-    protected function getWeight(array $ratingCounts, $ratingCountsSum, $powerOf2 = false)
199
-    {
200
-        return array_reduce(array_keys($ratingCounts),
201
-            function ($count, $rating) use ($ratingCounts, $ratingCountsSum, $powerOf2) {
202
-                $ratingLevel = $powerOf2
203
-                    ? pow($rating, 2)
204
-                    : $rating;
205
-                return $count + ($ratingLevel * ($ratingCounts[$rating] + 1)) / $ratingCountsSum;
206
-            }
207
-        );
208
-    }
193
+	/**
194
+	 * @param int|float $ratingCountsSum
195
+	 * @param bool $powerOf2
196
+	 * @return float
197
+	 */
198
+	protected function getWeight(array $ratingCounts, $ratingCountsSum, $powerOf2 = false)
199
+	{
200
+		return array_reduce(array_keys($ratingCounts),
201
+			function ($count, $rating) use ($ratingCounts, $ratingCountsSum, $powerOf2) {
202
+				$ratingLevel = $powerOf2
203
+					? pow($rating, 2)
204
+					: $rating;
205
+				return $count + ($ratingLevel * ($ratingCounts[$rating] + 1)) / $ratingCountsSum;
206
+			}
207
+		);
208
+	}
209 209
 }
Please login to merge, or discard this 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.
plugin/Controllers/RebusifyController.php 2 patches
Indentation   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -8,71 +8,71 @@
 block discarded – undo
8 8
 
9 9
 class RebusifyController extends Controller
10 10
 {
11
-    /**
12
-     * Triggered when a review is created
13
-     * @return void
14
-     * @action site-reviews/review/created
15
-     */
16
-    public function onCreated(Review $review)
17
-    {
18
-        if ($this->canProceed($review) && 'publish' === $review->status) {
19
-            $result = glsr(Rebusify::class)->sendReview($review);
20
-            // @todo
21
-        }
22
-    }
11
+	/**
12
+	 * Triggered when a review is created
13
+	 * @return void
14
+	 * @action site-reviews/review/created
15
+	 */
16
+	public function onCreated(Review $review)
17
+	{
18
+		if ($this->canProceed($review) && 'publish' === $review->status) {
19
+			$result = glsr(Rebusify::class)->sendReview($review);
20
+			// @todo
21
+		}
22
+	}
23 23
 
24
-    /**
25
-     * Triggered when a review is reverted to its original title/content/date_timestamp
26
-     * @return void
27
-     * @action site-reviews/review/reverted
28
-     */
29
-    public function onReverted(Review $review)
30
-    {
31
-        if ($this->canProceed($review) && 'publish' === $review->status) {
32
-            $result = glsr(Rebusify::class)->sendReview($review);
33
-            // @todo
34
-        }
35
-    }
24
+	/**
25
+	 * Triggered when a review is reverted to its original title/content/date_timestamp
26
+	 * @return void
27
+	 * @action site-reviews/review/reverted
28
+	 */
29
+	public function onReverted(Review $review)
30
+	{
31
+		if ($this->canProceed($review) && 'publish' === $review->status) {
32
+			$result = glsr(Rebusify::class)->sendReview($review);
33
+			// @todo
34
+		}
35
+	}
36 36
 
37
-    /**
38
-     * Triggered when an existing review is updated
39
-     * @return void
40
-     * @action site-reviews/review/saved
41
-     */
42
-    public function onSaved(Review $review)
43
-    {
44
-        if ($this->canProceed($review) && 'publish' === $review->status) {
45
-            $result = glsr(Rebusify::class)->sendReview($review);
46
-            // @todo
47
-        }
48
-    }
37
+	/**
38
+	 * Triggered when an existing review is updated
39
+	 * @return void
40
+	 * @action site-reviews/review/saved
41
+	 */
42
+	public function onSaved(Review $review)
43
+	{
44
+		if ($this->canProceed($review) && 'publish' === $review->status) {
45
+			$result = glsr(Rebusify::class)->sendReview($review);
46
+			// @todo
47
+		}
48
+	}
49 49
 
50
-    /**
51
-     * Triggered when a review's response is added or updated
52
-     * @param int $metaId
53
-     * @param int $postId
54
-     * @param string $metaKey
55
-     * @param mixed $metaValue
56
-     * @return void
57
-     * @action updated_postmeta
58
-     */
59
-    public function onUpdatedMeta($metaId, $postId, $metaKey, $metaValue)
60
-    {
61
-        if (!$this->isReviewPostId($postId) 
62
-            || !$this->canProceed($review) 
63
-            || '_response' !== $metaKey) {
64
-            return;
65
-        }
66
-        $review = glsr_get_review($postId);
67
-        $result = glsr(Rebusify::class)->sendReviewResponse($review);
68
-        // @todo
69
-    }
50
+	/**
51
+	 * Triggered when a review's response is added or updated
52
+	 * @param int $metaId
53
+	 * @param int $postId
54
+	 * @param string $metaKey
55
+	 * @param mixed $metaValue
56
+	 * @return void
57
+	 * @action updated_postmeta
58
+	 */
59
+	public function onUpdatedMeta($metaId, $postId, $metaKey, $metaValue)
60
+	{
61
+		if (!$this->isReviewPostId($postId) 
62
+			|| !$this->canProceed($review) 
63
+			|| '_response' !== $metaKey) {
64
+			return;
65
+		}
66
+		$review = glsr_get_review($postId);
67
+		$result = glsr(Rebusify::class)->sendReviewResponse($review);
68
+		// @todo
69
+	}
70 70
 
71
-    /**
72
-     * @return bool
73
-     */
74
-    protected function canProceed(Review $review)
75
-    {
76
-        return glsr(OptionManager::class)->getBool('settings.general.rebusify');
77
-    }
71
+	/**
72
+	 * @return bool
73
+	 */
74
+	protected function canProceed(Review $review)
75
+	{
76
+		return glsr(OptionManager::class)->getBool('settings.general.rebusify');
77
+	}
78 78
 }
Please login to merge, or discard this patch.
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -13,10 +13,10 @@  discard block
 block discarded – undo
13 13
      * @return void
14 14
      * @action site-reviews/review/created
15 15
      */
16
-    public function onCreated(Review $review)
16
+    public function onCreated( Review $review )
17 17
     {
18
-        if ($this->canProceed($review) && 'publish' === $review->status) {
19
-            $result = glsr(Rebusify::class)->sendReview($review);
18
+        if( $this->canProceed( $review ) && 'publish' === $review->status ) {
19
+            $result = glsr( Rebusify::class )->sendReview( $review );
20 20
             // @todo
21 21
         }
22 22
     }
@@ -26,10 +26,10 @@  discard block
 block discarded – undo
26 26
      * @return void
27 27
      * @action site-reviews/review/reverted
28 28
      */
29
-    public function onReverted(Review $review)
29
+    public function onReverted( Review $review )
30 30
     {
31
-        if ($this->canProceed($review) && 'publish' === $review->status) {
32
-            $result = glsr(Rebusify::class)->sendReview($review);
31
+        if( $this->canProceed( $review ) && 'publish' === $review->status ) {
32
+            $result = glsr( Rebusify::class )->sendReview( $review );
33 33
             // @todo
34 34
         }
35 35
     }
@@ -39,10 +39,10 @@  discard block
 block discarded – undo
39 39
      * @return void
40 40
      * @action site-reviews/review/saved
41 41
      */
42
-    public function onSaved(Review $review)
42
+    public function onSaved( Review $review )
43 43
     {
44
-        if ($this->canProceed($review) && 'publish' === $review->status) {
45
-            $result = glsr(Rebusify::class)->sendReview($review);
44
+        if( $this->canProceed( $review ) && 'publish' === $review->status ) {
45
+            $result = glsr( Rebusify::class )->sendReview( $review );
46 46
             // @todo
47 47
         }
48 48
     }
@@ -56,23 +56,23 @@  discard block
 block discarded – undo
56 56
      * @return void
57 57
      * @action updated_postmeta
58 58
      */
59
-    public function onUpdatedMeta($metaId, $postId, $metaKey, $metaValue)
59
+    public function onUpdatedMeta( $metaId, $postId, $metaKey, $metaValue )
60 60
     {
61
-        if (!$this->isReviewPostId($postId) 
62
-            || !$this->canProceed($review) 
63
-            || '_response' !== $metaKey) {
61
+        if( !$this->isReviewPostId( $postId ) 
62
+            || !$this->canProceed( $review ) 
63
+            || '_response' !== $metaKey ) {
64 64
             return;
65 65
         }
66
-        $review = glsr_get_review($postId);
67
-        $result = glsr(Rebusify::class)->sendReviewResponse($review);
66
+        $review = glsr_get_review( $postId );
67
+        $result = glsr( Rebusify::class )->sendReviewResponse( $review );
68 68
         // @todo
69 69
     }
70 70
 
71 71
     /**
72 72
      * @return bool
73 73
      */
74
-    protected function canProceed(Review $review)
74
+    protected function canProceed( Review $review )
75 75
     {
76
-        return glsr(OptionManager::class)->getBool('settings.general.rebusify');
76
+        return glsr( OptionManager::class )->getBool( 'settings.general.rebusify' );
77 77
     }
78 78
 }
Please login to merge, or discard this patch.