Passed
Push — master ( 7ac705...f4e23e )
by Paul
05:13
created
plugin/Helper.php 1 patch
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.