Test Setup Failed
Push — master ( 9dd233...41bd33 )
by Php Easy Api
04:18
created
src/resta/Support/Http.php 2 patches
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -28,9 +28,9 @@  discard block
 block discarded – undo
28 28
         // Fetch content and determine boundary
29 29
         $boundary = substr($raw_data, 0, strpos($raw_data, "\r\n"));
30 30
 
31
-        if(empty($boundary)){
32
-            parse_str($raw_data,$data);
33
-            $GLOBALS[ '_PUT' ] = $data;
31
+        if (empty($boundary)) {
32
+            parse_str($raw_data, $data);
33
+            $GLOBALS['_PUT'] = $data;
34 34
             return;
35 35
         }
36 36
 
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 
41 41
         foreach ($parts as $part) {
42 42
             // If this is the last part, break
43
-            if ($part == "--\r\n") break;
43
+            if ($part=="--\r\n") break;
44 44
 
45 45
             // Separate content from headers
46 46
             $part = ltrim($part, "\r\n");
@@ -67,10 +67,10 @@  discard block
 block discarded – undo
67 67
                 list(, $type, $name) = $matches;
68 68
 
69 69
                 //Parse File
70
-                if( isset($matches[4]) )
70
+                if (isset($matches[4]))
71 71
                 {
72 72
                     //if labeled the same as previous, skip
73
-                    if( isset( $_FILES[ $matches[ 2 ] ] ) )
73
+                    if (isset($_FILES[$matches[2]]))
74 74
                     {
75 75
                         continue;
76 76
                     }
@@ -79,16 +79,16 @@  discard block
 block discarded – undo
79 79
                     $filename = $matches[4];
80 80
 
81 81
                     //get tmp name
82
-                    $filename_parts = pathinfo( $filename );
83
-                    $tmp_name = tempnam( ini_get('upload_tmp_dir'), $filename_parts['filename']);
82
+                    $filename_parts = pathinfo($filename);
83
+                    $tmp_name = tempnam(ini_get('upload_tmp_dir'), $filename_parts['filename']);
84 84
 
85 85
                     //populate $_FILES with information, size may be off in multibyte situation
86 86
                     /** @noinspection PhpUndefinedVariableInspection */
87
-                    $_FILES[ $matches[ 2 ] ] = array(
87
+                    $_FILES[$matches[2]] = array(
88 88
                         'error'=>0,
89 89
                         'name'=>$filename,
90 90
                         'tmp_name'=>$tmp_name,
91
-                        'size'=>strlen( $body ),
91
+                        'size'=>strlen($body),
92 92
                         'type'=>$value
93 93
                     );
94 94
 
@@ -98,12 +98,12 @@  discard block
 block discarded – undo
98 98
                 //Parse Field
99 99
                 else
100 100
                 {
101
-                    $data[$name] = substr($body, 0, strlen($body) - 2);
101
+                    $data[$name] = substr($body, 0, strlen($body)-2);
102 102
                 }
103 103
             }
104 104
 
105 105
         }
106
-        $GLOBALS[ '_PUT' ] = $data;
106
+        $GLOBALS['_PUT'] = $data;
107 107
         return $data;
108 108
     }
109 109
 
@@ -111,34 +111,34 @@  discard block
 block discarded – undo
111 111
      * @param string $method
112 112
      * @return array
113 113
      */
114
-    public function httpMethodData($method='get')
114
+    public function httpMethodData($method = 'get')
115 115
     {
116 116
         $body = [];
117
-        if(httpMethod()==$method){
118
-            $rawData = json_decode(request()->getContent(),1);
117
+        if (httpMethod()==$method) {
118
+            $rawData = json_decode(request()->getContent(), 1);
119 119
 
120 120
             $get = get();
121
-            if(is_array($get) && count($get)){
121
+            if (is_array($get) && count($get)) {
122 122
                 $body['params'] = get();
123 123
             }
124 124
 
125
-            if(is_null($rawData)){
125
+            if (is_null($rawData)) {
126 126
                 $inputData = $this->getInputData();
127 127
 
128
-                if(!is_null($inputData)){
128
+                if (!is_null($inputData)) {
129 129
                     $body['body']['form-data'] = $this->getInputData();
130 130
                 }
131
-                else{
131
+                else {
132 132
 
133 133
                     $all = request()->request->all();
134
-                    if(is_array($all) && count($all)){
134
+                    if (is_array($all) && count($all)) {
135 135
                         $body['body']['x-www-form-urlencoded'] = $all;
136 136
                     }
137 137
 
138 138
                 }
139 139
 
140 140
             }
141
-            else{
141
+            else {
142 142
                 $body['body']['raw-data'] = $rawData;
143 143
             }
144 144
         }
Please login to merge, or discard this patch.
Braces   +8 added lines, -7 removed lines patch added patch discarded remove patch
@@ -19,8 +19,9 @@  discard block
 block discarded – undo
19 19
 
20 20
         /* Read the data 1 KB at a time
21 21
            and write to the file */
22
-        while ($chunk = fread($putdata, 1024))
23
-            $raw_data .= $chunk;
22
+        while ($chunk = fread($putdata, 1024)) {
23
+                    $raw_data .= $chunk;
24
+        }
24 25
 
25 26
         /* Close the streams */
26 27
         fclose($putdata);
@@ -40,7 +41,9 @@  discard block
 block discarded – undo
40 41
 
41 42
         foreach ($parts as $part) {
42 43
             // If this is the last part, break
43
-            if ($part == "--\r\n") break;
44
+            if ($part == "--\r\n") {
45
+                break;
46
+            }
44 47
 
45 48
             // Separate content from headers
46 49
             $part = ltrim($part, "\r\n");
@@ -127,8 +130,7 @@  discard block
 block discarded – undo
127 130
 
128 131
                 if(!is_null($inputData)){
129 132
                     $body['body']['form-data'] = $this->getInputData();
130
-                }
131
-                else{
133
+                } else{
132 134
 
133 135
                     $all = request()->request->all();
134 136
                     if(is_array($all) && count($all)){
@@ -137,8 +139,7 @@  discard block
 block discarded – undo
137 139
 
138 140
                 }
139 141
 
140
-            }
141
-            else{
142
+            } else{
142 143
                 $body['body']['raw-data'] = $rawData;
143 144
             }
144 145
         }
Please login to merge, or discard this patch.