Passed
Push — master ( 7ac705...f4e23e )
by Paul
05:13
created
plugin/Helper.php 2 patches
Indentation   +113 added lines, -113 removed lines patch added patch discarded remove patch
@@ -9,124 +9,124 @@
 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 'bool':
59
-            case 'boolean':
60
-                return filter_var($value, FILTER_VALIDATE_BOOLEAN);
61
-            case 'float':
62
-                return (float) filter_var($value, FILTER_VALIDATE_FLOAT, FILTER_FLAG_ALLOW_THOUSAND);
63
-            case 'int':
64
-            case 'integer':
65
-                return (int) filter_var($value, FILTER_VALIDATE_INT);
66
-            case 'object':
67
-                return (object) (array) $value;
68
-            case 'str':
69
-            case 'string':
70
-                if (is_object($value) && in_array('__toString', get_class_methods($value))) {
71
-                    return (string) $value->__toString();
72
-                }
73
-                if (is_array($value) || is_object($value)) {
74
-                    return serialize($value);
75
-                }
76
-                return (string) $value;
77
-            default:
78
-                return $value;
79
-        }
80
-    }
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 'bool':
59
+			case 'boolean':
60
+				return filter_var($value, FILTER_VALIDATE_BOOLEAN);
61
+			case 'float':
62
+				return (float) filter_var($value, FILTER_VALIDATE_FLOAT, FILTER_FLAG_ALLOW_THOUSAND);
63
+			case 'int':
64
+			case 'integer':
65
+				return (int) filter_var($value, FILTER_VALIDATE_INT);
66
+			case 'object':
67
+				return (object) (array) $value;
68
+			case 'str':
69
+			case 'string':
70
+				if (is_object($value) && in_array('__toString', get_class_methods($value))) {
71
+					return (string) $value->__toString();
72
+				}
73
+				if (is_array($value) || is_object($value)) {
74
+					return serialize($value);
75
+				}
76
+				return (string) $value;
77
+			default:
78
+				return $value;
79
+		}
80
+	}
81 81
 
82
-    /**
83
-     * @param string $key
84
-     * @return mixed
85
-     */
86
-    public function filterInput($key, array $request = [])
87
-    {
88
-        if (isset($request[$key])) {
89
-            return $request[$key];
90
-        }
91
-        $variable = filter_input(INPUT_POST, $key);
92
-        if (is_null($variable) && isset($_POST[$key])) {
93
-            $variable = $_POST[$key];
94
-        }
95
-        return $variable;
96
-    }
82
+	/**
83
+	 * @param string $key
84
+	 * @return mixed
85
+	 */
86
+	public function filterInput($key, array $request = [])
87
+	{
88
+		if (isset($request[$key])) {
89
+			return $request[$key];
90
+		}
91
+		$variable = filter_input(INPUT_POST, $key);
92
+		if (is_null($variable) && isset($_POST[$key])) {
93
+			$variable = $_POST[$key];
94
+		}
95
+		return $variable;
96
+	}
97 97
 
98
-    /**
99
-     * @param string $key
100
-     * @return array
101
-     */
102
-    public function filterInputArray($key)
103
-    {
104
-        $variable = filter_input(INPUT_POST, $key, FILTER_DEFAULT, FILTER_REQUIRE_ARRAY);
105
-        if (empty($variable) && !empty($_POST[$key]) && is_array($_POST[$key])) {
106
-            $variable = $_POST[$key];
107
-        }
108
-        return (array) $variable;
109
-    }
98
+	/**
99
+	 * @param string $key
100
+	 * @return array
101
+	 */
102
+	public function filterInputArray($key)
103
+	{
104
+		$variable = filter_input(INPUT_POST, $key, FILTER_DEFAULT, FILTER_REQUIRE_ARRAY);
105
+		if (empty($variable) && !empty($_POST[$key]) && is_array($_POST[$key])) {
106
+			$variable = $_POST[$key];
107
+		}
108
+		return (array) $variable;
109
+	}
110 110
 
111
-    /**
112
-     * @return string
113
-     */
114
-    public function getIpAddress()
115
-    {
116
-        $cloudflareIps = glsr(Cache::class)->getCloudflareIps();
117
-        $whitelist = [
118
-            Whip::CLOUDFLARE_HEADERS => [Whip::IPV4 => $cloudflareIps['v4']],
119
-            // Whip::CUSTOM_HEADERS => [Whip::IPV4 => ['127.0.0.1']],
120
-        ];
121
-        if (defined('AF_INET6')) {
122
-            $whitelist[Whip::CLOUDFLARE_HEADERS][Whip::IPV6] = $cloudflareIps['v6'];
123
-            // $whitelist[Whip::CUSTOM_HEADERS][Whip::IPV6] = ['::1'];
124
-        }
125
-        $whitelist = apply_filters('site-reviews/whip/whitelist', $whitelist);
126
-        $methods = Whip::CUSTOM_HEADERS | Whip::CLOUDFLARE_HEADERS | Whip::REMOTE_ADDR;
127
-        $methods = apply_filters('site-reviews/whip/methods', $methods);
128
-        $whip = new Whip($methods, $whitelist);
129
-        do_action_ref_array('site-reviews/whip', [$whip]);
130
-        return (string) $whip->getValidIpAddress();
131
-    }
111
+	/**
112
+	 * @return string
113
+	 */
114
+	public function getIpAddress()
115
+	{
116
+		$cloudflareIps = glsr(Cache::class)->getCloudflareIps();
117
+		$whitelist = [
118
+			Whip::CLOUDFLARE_HEADERS => [Whip::IPV4 => $cloudflareIps['v4']],
119
+			// Whip::CUSTOM_HEADERS => [Whip::IPV4 => ['127.0.0.1']],
120
+		];
121
+		if (defined('AF_INET6')) {
122
+			$whitelist[Whip::CLOUDFLARE_HEADERS][Whip::IPV6] = $cloudflareIps['v6'];
123
+			// $whitelist[Whip::CUSTOM_HEADERS][Whip::IPV6] = ['::1'];
124
+		}
125
+		$whitelist = apply_filters('site-reviews/whip/whitelist', $whitelist);
126
+		$methods = Whip::CUSTOM_HEADERS | Whip::CLOUDFLARE_HEADERS | Whip::REMOTE_ADDR;
127
+		$methods = apply_filters('site-reviews/whip/methods', $methods);
128
+		$whip = new Whip($methods, $whitelist);
129
+		do_action_ref_array('site-reviews/whip', [$whip]);
130
+		return (string) $whip->getValidIpAddress();
131
+	}
132 132
 }
Please login to merge, or discard this patch.
Spacing   +34 added lines, -34 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,30 +50,30 @@  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 'bool':
59 59
             case 'boolean':
60
-                return filter_var($value, FILTER_VALIDATE_BOOLEAN);
60
+                return filter_var( $value, FILTER_VALIDATE_BOOLEAN );
61 61
             case 'float':
62
-                return (float) filter_var($value, FILTER_VALIDATE_FLOAT, FILTER_FLAG_ALLOW_THOUSAND);
62
+                return (float)filter_var( $value, FILTER_VALIDATE_FLOAT, FILTER_FLAG_ALLOW_THOUSAND );
63 63
             case 'int':
64 64
             case 'integer':
65
-                return (int) filter_var($value, FILTER_VALIDATE_INT);
65
+                return (int)filter_var( $value, FILTER_VALIDATE_INT );
66 66
             case 'object':
67
-                return (object) (array) $value;
67
+                return (object)(array)$value;
68 68
             case 'str':
69 69
             case 'string':
70
-                if (is_object($value) && in_array('__toString', get_class_methods($value))) {
71
-                    return (string) $value->__toString();
70
+                if( is_object( $value ) && in_array( '__toString', get_class_methods( $value ) ) ) {
71
+                    return (string)$value->__toString();
72 72
                 }
73
-                if (is_array($value) || is_object($value)) {
74
-                    return serialize($value);
73
+                if( is_array( $value ) || is_object( $value ) ) {
74
+                    return serialize( $value );
75 75
                 }
76
-                return (string) $value;
76
+                return (string)$value;
77 77
             default:
78 78
                 return $value;
79 79
         }
@@ -83,13 +83,13 @@  discard block
 block discarded – undo
83 83
      * @param string $key
84 84
      * @return mixed
85 85
      */
86
-    public function filterInput($key, array $request = [])
86
+    public function filterInput( $key, array $request = [] )
87 87
     {
88
-        if (isset($request[$key])) {
88
+        if( isset($request[$key]) ) {
89 89
             return $request[$key];
90 90
         }
91
-        $variable = filter_input(INPUT_POST, $key);
92
-        if (is_null($variable) && isset($_POST[$key])) {
91
+        $variable = filter_input( INPUT_POST, $key );
92
+        if( is_null( $variable ) && isset($_POST[$key]) ) {
93 93
             $variable = $_POST[$key];
94 94
         }
95 95
         return $variable;
@@ -99,13 +99,13 @@  discard block
 block discarded – undo
99 99
      * @param string $key
100 100
      * @return array
101 101
      */
102
-    public function filterInputArray($key)
102
+    public function filterInputArray( $key )
103 103
     {
104
-        $variable = filter_input(INPUT_POST, $key, FILTER_DEFAULT, FILTER_REQUIRE_ARRAY);
105
-        if (empty($variable) && !empty($_POST[$key]) && is_array($_POST[$key])) {
104
+        $variable = filter_input( INPUT_POST, $key, FILTER_DEFAULT, FILTER_REQUIRE_ARRAY );
105
+        if( empty($variable) && !empty($_POST[$key]) && is_array( $_POST[$key] ) ) {
106 106
             $variable = $_POST[$key];
107 107
         }
108
-        return (array) $variable;
108
+        return (array)$variable;
109 109
     }
110 110
 
111 111
     /**
@@ -113,20 +113,20 @@  discard block
 block discarded – undo
113 113
      */
114 114
     public function getIpAddress()
115 115
     {
116
-        $cloudflareIps = glsr(Cache::class)->getCloudflareIps();
116
+        $cloudflareIps = glsr( Cache::class )->getCloudflareIps();
117 117
         $whitelist = [
118 118
             Whip::CLOUDFLARE_HEADERS => [Whip::IPV4 => $cloudflareIps['v4']],
119 119
             // Whip::CUSTOM_HEADERS => [Whip::IPV4 => ['127.0.0.1']],
120 120
         ];
121
-        if (defined('AF_INET6')) {
121
+        if( defined( 'AF_INET6' ) ) {
122 122
             $whitelist[Whip::CLOUDFLARE_HEADERS][Whip::IPV6] = $cloudflareIps['v6'];
123 123
             // $whitelist[Whip::CUSTOM_HEADERS][Whip::IPV6] = ['::1'];
124 124
         }
125
-        $whitelist = apply_filters('site-reviews/whip/whitelist', $whitelist);
125
+        $whitelist = apply_filters( 'site-reviews/whip/whitelist', $whitelist );
126 126
         $methods = Whip::CUSTOM_HEADERS | Whip::CLOUDFLARE_HEADERS | Whip::REMOTE_ADDR;
127
-        $methods = apply_filters('site-reviews/whip/methods', $methods);
128
-        $whip = new Whip($methods, $whitelist);
129
-        do_action_ref_array('site-reviews/whip', [$whip]);
130
-        return (string) $whip->getValidIpAddress();
127
+        $methods = apply_filters( 'site-reviews/whip/methods', $methods );
128
+        $whip = new Whip( $methods, $whitelist );
129
+        do_action_ref_array( 'site-reviews/whip', [$whip] );
130
+        return (string)$whip->getValidIpAddress();
131 131
     }
132 132
 }
Please login to merge, or discard this patch.