Passed
Push — master ( b8d8a1...bb6f0e )
by Chris
02:34
created
src/utils.php 3 patches
Doc Comments   +4 added lines patch added patch discarded remove patch
@@ -155,6 +155,10 @@
 block discarded – undo
155 155
         return self::get_request_value_int( 'SERVER', $key, $default_value );
156 156
     }
157 157
 
158
+    /**
159
+     * @param string $request_method
160
+     * @param string $key
161
+     */
158 162
     public static function get_request_value_int( $request_method, $key, $default_value = null )
159 163
     {
160 164
         $value = self::get_request_value( $request_method, $key, null );
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -313,17 +313,17 @@
 block discarded – undo
313 313
      * @param  array $parsed_url An array created by urlpieces.
314 314
      * @return string            A URL string.
315 315
      */
316
-    public static function unparse_url( $parsed_url ) {
316
+    public static function unparse_url( $parsed_url ){
317 317
         //I don't know what you gave me so you can just have it back
318
-        if( ! is_array( $parsed_url ) ) {
318
+        if( ! is_array( $parsed_url ) ){
319 319
             return $parsed_url;
320 320
         }
321
-        $scheme   = isset( $parsed_url['scheme'])    ?       $parsed_url['scheme'] . '://' : '';
322
-        $host     = isset( $parsed_url['host'] )     ?       $parsed_url['host']           : '';
323
-        $port     = isset( $parsed_url['port'] )     ? ':' . $parsed_url['port']           : '';
324
-        $path     = isset( $parsed_url['path'] )     ?       $parsed_url['path']           : '';
325
-        $query    = isset( $parsed_url['query'] )    ? '?' . $parsed_url['query']          : '';
326
-        $fragment = isset( $parsed_url['fragment'] ) ? '#' . $parsed_url['fragment']       : '';
321
+        $scheme   = isset( $parsed_url[ 'scheme' ] ) ? $parsed_url[ 'scheme' ] . '://' : '';
322
+        $host     = isset( $parsed_url[ 'host' ] ) ? $parsed_url[ 'host' ] : '';
323
+        $port     = isset( $parsed_url[ 'port' ] ) ? ':' . $parsed_url[ 'port' ] : '';
324
+        $path     = isset( $parsed_url[ 'path' ] ) ? $parsed_url[ 'path' ] : '';
325
+        $query    = isset( $parsed_url[ 'query' ] ) ? '?' . $parsed_url[ 'query' ] : '';
326
+        $fragment = isset( $parsed_url[ 'fragment' ] ) ? '#' . $parsed_url[ 'fragment' ] : '';
327 327
 
328 328
         //NOTE: user and pass were explicitly removed.
329 329
 
Please login to merge, or discard this patch.
Braces   +64 added lines, -62 removed lines patch added patch discarded remove patch
@@ -8,8 +8,8 @@  discard block
 block discarded – undo
8 8
 
9 9
 namespace Vendi\Shared;
10 10
 
11
-class utils
12
-{
11
+class utils
12
+{
13 13
     public static $CUSTOM_POST = null;
14 14
 
15 15
     public static $CUSTOM_GET = null;
@@ -18,8 +18,8 @@  discard block
 block discarded – undo
18 18
 
19 19
     public static $CUSTOM_SERVER = null;
20 20
 
21
-    public static function reset_all_custom_arrays()
22
-    {
21
+    public static function reset_all_custom_arrays()
22
+    {
23 23
         self::$CUSTOM_POST = null;
24 24
         self::$CUSTOM_GET = null;
25 25
         self::$CUSTOM_COOKIE = null;
@@ -32,8 +32,8 @@  discard block
 block discarded – undo
32 32
      * @param  mixed         $default_value Optional. If the $key cannot be found the value to return. Default null.
33 33
      * @return mixed                        The value of the HTTP POST for the given $key or the $default.
34 34
      */
35
-    public static function get_post_value( $key, $default_value = '' )
36
-    {
35
+    public static function get_post_value( $key, $default_value = '' )
36
+    {
37 37
         return self::get_request_value( 'POST', $key, $default_value );
38 38
     }
39 39
 
@@ -43,8 +43,8 @@  discard block
 block discarded – undo
43 43
      * @param  mixed         $default_value Optional. If the $key cannot be found the value to return. Default null.
44 44
      * @return mixed                        The value of the HTTP GET for the given $key or the $default.
45 45
      */
46
-    public static function get_get_value( $key, $default_value = '' )
47
-    {
46
+    public static function get_get_value( $key, $default_value = '' )
47
+    {
48 48
         return self::get_request_value( 'GET', $key, $default_value );
49 49
     }
50 50
 
@@ -54,8 +54,8 @@  discard block
 block discarded – undo
54 54
      * @param  mixed         $default_value Optional. If the $key cannot be found the value to return. Default null.
55 55
      * @return mixed                        The value of the HTTP COOKIE for the given $key or the $default.
56 56
      */
57
-    public static function get_cookie_value( $key, $default_value = '' )
58
-    {
57
+    public static function get_cookie_value( $key, $default_value = '' )
58
+    {
59 59
         return self::get_request_value( 'COOKIE', $key, $default_value );
60 60
     }
61 61
 
@@ -65,8 +65,8 @@  discard block
 block discarded – undo
65 65
      * @param  mixed         $default_value Optional. If the $key cannot be found the value to return. Default null.
66 66
      * @return mixed                        The value of the HTTP SERVER for the given $key or the $default.
67 67
      */
68
-    public static function get_server_value( $key, $default_value = '' )
69
-    {
68
+    public static function get_server_value( $key, $default_value = '' )
69
+    {
70 70
         return self::get_request_value( 'SERVER', $key, $default_value );
71 71
     }
72 72
 
@@ -78,13 +78,13 @@  discard block
 block discarded – undo
78 78
      * @param  mixed         $default_value Optional. If the $key cannot be found the value to return. Default null.
79 79
      * @return mixed                        The value of the source for the given $key or the $default.
80 80
      */
81
-    public static function get_value_multiple_sources( $key, array $sources, $default_value = null )
82
-    {
83
-        foreach( $sources as $source )
84
-        {
81
+    public static function get_value_multiple_sources( $key, array $sources, $default_value = null )
82
+    {
83
+        foreach( $sources as $source )
84
+        {
85 85
             $value = self::get_request_value( $source, $key, null );
86
-            if( null !== $value )
87
-            {
86
+            if( null !== $value )
87
+            {
88 88
                 return $value;
89 89
             }
90 90
         }
@@ -98,8 +98,8 @@  discard block
 block discarded – undo
98 98
      * @param  integer|mixed $default_value Optional. If the $key cannot be found the value to return. Default null.
99 99
      * @return integer|mixed                The value of the HTTP POST for the given $key or the $default.
100 100
      */
101
-    public static function get_post_value_int( $key, $default_value = null )
102
-    {
101
+    public static function get_post_value_int( $key, $default_value = null )
102
+    {
103 103
         return self::get_request_value_int( 'POST', $key, $default_value );
104 104
     }
105 105
 
@@ -109,8 +109,8 @@  discard block
 block discarded – undo
109 109
      * @param  integer|mixed $default_value Optional. If the $key cannot be found the value to return. Default null.
110 110
      * @return integer|mixed                The value of the HTTP GET for the given $key or the $default.
111 111
      */
112
-    public static function get_get_value_int( $key, $default_value = null )
113
-    {
112
+    public static function get_get_value_int( $key, $default_value = null )
113
+    {
114 114
         return self::get_request_value_int( 'GET', $key, $default_value );
115 115
     }
116 116
 
@@ -120,8 +120,8 @@  discard block
 block discarded – undo
120 120
      * @param  integer|mixed $default_value Optional. If the $key cannot be found the value to return. Default null.
121 121
      * @return integer|mixed                The value of the HTTP COOKIE for the given $key or the $default.
122 122
      */
123
-    public static function get_cookie_value_int( $key, $default_value = null )
124
-    {
123
+    public static function get_cookie_value_int( $key, $default_value = null )
124
+    {
125 125
         return self::get_request_value_int( 'COOKIE', $key, $default_value );
126 126
     }
127 127
 
@@ -131,70 +131,70 @@  discard block
 block discarded – undo
131 131
      * @param  integer|mixed $default_value Optional. If the $key cannot be found the value to return. Default null.
132 132
      * @return integer|mixed                The value of the HTTP SERVER for the given $key or the $default.
133 133
      */
134
-    public static function get_server_value_int( $key, $default_value = null )
135
-    {
134
+    public static function get_server_value_int( $key, $default_value = null )
135
+    {
136 136
         return self::get_request_value_int( 'SERVER', $key, $default_value );
137 137
     }
138 138
 
139
-    public static function get_request_value_int( $request_method, $key, $default_value = null )
140
-    {
139
+    public static function get_request_value_int( $request_method, $key, $default_value = null )
140
+    {
141 141
         $value = self::get_request_value( $request_method, $key, null );
142
-        if( self::is_integer_like( $value ) )
143
-        {
142
+        if( self::is_integer_like( $value ) )
143
+        {
144 144
             return (int)$value;
145 145
         }
146 146
 
147 147
         return $default_value;
148 148
     }
149 149
 
150
-    public static function get_request_value( $request_method, $key, $default_value = null )
151
-    {
150
+    public static function get_request_value( $request_method, $key, $default_value = null )
151
+    {
152 152
         $request_obj = self::get_request_object( $request_method );
153 153
 
154
-        if( null === $request_obj || ! is_array( $request_obj ) || ! array_key_exists( $key, $request_obj ) )
155
-        {
154
+        if( null === $request_obj || ! is_array( $request_obj ) || ! array_key_exists( $key, $request_obj ) )
155
+        {
156 156
             return $default_value;
157 157
         }
158 158
 
159 159
         $ret = $request_obj[ $key ];
160 160
 
161
-        if( is_string( $ret ) )
162
-        {
161
+        if( is_string( $ret ) )
162
+        {
163 163
             $ret = trim( $ret );
164 164
         }
165 165
 
166 166
         return $ret;
167 167
     }
168 168
 
169
-    public static function get_request_object( $request_method )
170
-    {
169
+    public static function get_request_object( $request_method )
170
+    {
171 171
         $obj = null;
172
-        switch( $request_method )
173
-        {
172
+        switch( $request_method )
173
+        {
174 174
             case 'GET':
175
-                if( is_array( self::$CUSTOM_GET ) )
176
-                {
175
+                if( is_array( self::$CUSTOM_GET ) )
176
+                {
177 177
                     return self::$CUSTOM_GET;
178 178
                 }
179 179
                 return ( isset( $_GET ) && is_array( $_GET ) && count( $_GET ) > 0 ? $_GET : null );
180 180
 
181 181
             case 'POST':
182
-                if( is_array( self::$CUSTOM_POST ) )
183
-                {
182
+                if( is_array( self::$CUSTOM_POST ) )
183
+                {
184 184
                     return self::$CUSTOM_POST;
185 185
                 }
186 186
                 return ( isset( $_POST ) && is_array( $_POST ) && count( $_POST ) > 0 ? $_POST : null );
187 187
 
188 188
             case 'COOKIE':
189
-                if( is_array( self::$CUSTOM_COOKIE ) )
190
-                {
189
+                if( is_array( self::$CUSTOM_COOKIE ) )
190
+                {
191 191
                     return self::$CUSTOM_COOKIE;
192 192
                 }
193 193
                 return ( isset( $_COOKIE ) && is_array( $_COOKIE ) && count( $_COOKIE ) > 0 ? $_COOKIE : null );
194 194
 
195 195
             case 'SERVER':
196
-                if( is_array( self::$CUSTOM_SERVER ) )
197
-                {
196
+                if( is_array( self::$CUSTOM_SERVER ) )
197
+                {
198 198
                     return self::$CUSTOM_SERVER;
199 199
                 }
200 200
                 return ( isset( $_SERVER ) && is_array( $_SERVER ) && count( $_SERVER ) > 0 ? $_SERVER : null );
@@ -210,8 +210,8 @@  discard block
 block discarded – undo
210 210
      * @param  string  $method The server method to test for. Generally one of GET, POST, HEAD, PUT, DELETE.
211 211
      * @return boolean         Returns true if the REQUEST_METHOD server variable is set to the supplied $method, otherwise false.
212 212
      */
213
-    public static function is_request_method( $method )
214
-    {
213
+    public static function is_request_method( $method )
214
+    {
215 215
         return $method === self::get_server_value( 'REQUEST_METHOD' );
216 216
     }
217 217
 
@@ -225,8 +225,8 @@  discard block
 block discarded – undo
225 225
      *
226 226
      * @return boolean Returns true if the REQUEST_METHOD server variable is set to POST, otherwise false.
227 227
      */
228
-    public static function is_post( )
229
-    {
228
+    public static function is_post( )
229
+    {
230 230
         return self::is_request_method( 'POST' );
231 231
     }
232 232
 
@@ -238,8 +238,8 @@  discard block
 block discarded – undo
238 238
      * @param  mixed  $input The value to test.
239 239
      * @return boolean       True if $input is an integer or a string that contains only digits possibly starting with a dash.
240 240
      */
241
-    public static function is_integer_like( $input )
242
-    {
241
+    public static function is_integer_like( $input )
242
+    {
243 243
         return
244 244
                 is_int( $input )
245 245
                 ||
@@ -250,13 +250,13 @@  discard block
 block discarded – undo
250 250
                 );
251 251
     }
252 252
 
253
-    public static function get_all_headers()
254
-    {
253
+    public static function get_all_headers()
254
+    {
255 255
         $headers = array();
256
-        foreach( array( '_SERVER', '_GET', '_POST', '_COOKIE', '_ENV' ) as $key )
257
-        {
258
-            if( array_key_exists( $key, $GLOBALS ) )
259
-            {
256
+        foreach( array( '_SERVER', '_GET', '_POST', '_COOKIE', '_ENV' ) as $key )
257
+        {
258
+            if( array_key_exists( $key, $GLOBALS ) )
259
+            {
260 260
 
261 261
             }
262 262
             $headers[ $key ] = $GLOBALS[ $key ];
@@ -272,9 +272,11 @@  discard block
 block discarded – undo
272 272
      * @param  array $parsed_url An array created by urlpieces.
273 273
      * @return string            A URL string.
274 274
      */
275
-    public static function unparse_url( $parsed_url ) {
275
+    public static function unparse_url( $parsed_url )
276
+    {
276 277
         //I don't know what you gave me so you can just have it back
277
-        if( ! is_array( $parsed_url ) ) {
278
+        if( ! is_array( $parsed_url ) )
279
+        {
278 280
             return $parsed_url;
279 281
         }
280 282
         $scheme   = isset( $parsed_url['scheme'])    ?       $parsed_url['scheme'] . '://' : '';
Please login to merge, or discard this patch.