Reformat source code: the library
[plcapi.git] / src / Helper / Http.php
index 83a3737..02bfd57 100644 (file)
@@ -7,9 +7,10 @@ class Http
     /**
      * decode a string that is encoded w/ "chunked" transfer encoding
      * as defined in rfc2068 par. 19.4.6
-     * code shamelessly stolen from nusoap library by Dietrich Ayala
+     * code shamelessly stolen from nusoap library by Dietrich Ayala.
      *
      * @param string $buffer the string to be decoded
+     *
      * @return string
      */
     public static function decode_chunked($buffer)
@@ -20,18 +21,16 @@ class Http
 
         // read chunk-size, chunk-extension (if any) and crlf
         // get the position of the linebreak
-        $chunkend = strpos($buffer,"\r\n") + 2;
-        $temp = substr($buffer,0,$chunkend);
-        $chunk_size = hexdec( trim($temp) );
+        $chunkend = strpos($buffer, "\r\n") + 2;
+        $temp = substr($buffer, 0, $chunkend);
+        $chunk_size = hexdec(trim($temp));
         $chunkstart = $chunkend;
-        while($chunk_size > 0)
-        {
+        while ($chunk_size > 0) {
             $chunkend = strpos($buffer, "\r\n", $chunkstart + $chunk_size);
 
             // just in case we got a broken connection
-            if($chunkend == false)
-            {
-                $chunk = substr($buffer,$chunkstart);
+            if ($chunkend == false) {
+                $chunk = substr($buffer, $chunkstart);
                 // append chunk-data to entity-body
                 $new .= $chunk;
                 $length += strlen($chunk);
@@ -39,7 +38,7 @@ class Http
             }
 
             // read chunk-data and crlf
-            $chunk = substr($buffer,$chunkstart,$chunkend-$chunkstart);
+            $chunk = substr($buffer, $chunkstart, $chunkend - $chunkstart);
             // append chunk-data to entity-body
             $new .= $chunk;
             // length := length + chunk-size
@@ -47,16 +46,15 @@ class Http
             // read chunk-size and crlf
             $chunkstart = $chunkend + 2;
 
-            $chunkend = strpos($buffer,"\r\n",$chunkstart)+2;
-            if($chunkend == false)
-            {
+            $chunkend = strpos($buffer, "\r\n", $chunkstart) + 2;
+            if ($chunkend == false) {
                 break; //just in case we got a broken connection
             }
-            $temp = substr($buffer,$chunkstart,$chunkend-$chunkstart);
-            $chunk_size = hexdec( trim($temp) );
+            $temp = substr($buffer, $chunkstart, $chunkend - $chunkstart);
+            $chunk_size = hexdec(trim($temp));
             $chunkstart = $chunkend;
         }
+
         return $new;
     }
-
-}
\ No newline at end of file
+}