Test Failed
Push — master ( 87f942...2b3f4c )
by Raffael
53:31 queued 51:46
created
src/app/Balloon.App.Api/Helper.php 1 patch
Indentation   +64 added lines, -64 removed lines patch added patch discarded remove patch
@@ -40,69 +40,69 @@
 block discarded – undo
40 40
         }
41 41
 
42 42
         return $response
43
-          ->setOutputFormat(null)
44
-          ->setBody(function () use ($file) {
45
-              $stream = $file->get();
46
-              $name = $file->getName();
47
-
48
-              if (null === $stream) {
49
-                  return;
50
-              }
51
-
52
-              $size = $file->getSize();
53
-              $length = $size;
54
-              $start = 0;
55
-              $end = $size - 1;
56
-
57
-              set_time_limit(0);
58
-              if (isset($_SERVER['HTTP_RANGE'])) {
59
-                  header('Accept-Ranges: bytes');
60
-                  $c_start = $start;
61
-                  $c_end = $end;
62
-                  list(, $range) = explode('=', $_SERVER['HTTP_RANGE'], 2);
63
-
64
-                  if (strpos($range, ',') !== false) {
65
-                      header("Content-Range: bytes $start-$end/$size");
66
-
67
-                      throw new Exception\InvalidRange('invalid offset/limit requested');
68
-                  }
69
-
70
-                  if ($range == '-') {
71
-                      $c_start = $size - substr($range, 1);
72
-                  } else {
73
-                      $range = explode('-', $range);
74
-                      $c_start = $range[0];
75
-                      $c_end = (isset($range[1]) && is_numeric($range[1])) ? $range[1] : $size;
76
-                  }
77
-
78
-                  $c_end = ($c_end > $end) ? $end : $c_end;
79
-                  if ($c_start > $c_end || $c_start > $size - 1 || $c_end >= $size) {
80
-                      header("Content-Range: bytes $start-$end/$size");
81
-
82
-                      throw new Exception\InvalidRange('invalid offset/limit requested');
83
-                  }
84
-
85
-                  $start = (int) $c_start;
86
-                  $end = (int) $c_end;
87
-                  $length = (int) $end - $start + 1;
88
-                  fseek($stream, $start);
89
-                  header('HTTP/1.1 206 Partial Content');
90
-                  header("Content-Range: bytes $start-$end/$size");
91
-              }
92
-
93
-              header('Content-Length: '.$length);
94
-              $buffer = 1024 * 8;
95
-
96
-              while (!feof($stream) && ($p = ftell($stream)) <= $end) {
97
-                  if ($p + $buffer > $end) {
98
-                      $buffer = $end - $p + 1;
99
-                  }
100
-
101
-                  echo fread($stream, $buffer);
102
-                  flush();
103
-              }
104
-
105
-              fclose($stream);
106
-          });
43
+            ->setOutputFormat(null)
44
+            ->setBody(function () use ($file) {
45
+                $stream = $file->get();
46
+                $name = $file->getName();
47
+
48
+                if (null === $stream) {
49
+                    return;
50
+                }
51
+
52
+                $size = $file->getSize();
53
+                $length = $size;
54
+                $start = 0;
55
+                $end = $size - 1;
56
+
57
+                set_time_limit(0);
58
+                if (isset($_SERVER['HTTP_RANGE'])) {
59
+                    header('Accept-Ranges: bytes');
60
+                    $c_start = $start;
61
+                    $c_end = $end;
62
+                    list(, $range) = explode('=', $_SERVER['HTTP_RANGE'], 2);
63
+
64
+                    if (strpos($range, ',') !== false) {
65
+                        header("Content-Range: bytes $start-$end/$size");
66
+
67
+                        throw new Exception\InvalidRange('invalid offset/limit requested');
68
+                    }
69
+
70
+                    if ($range == '-') {
71
+                        $c_start = $size - substr($range, 1);
72
+                    } else {
73
+                        $range = explode('-', $range);
74
+                        $c_start = $range[0];
75
+                        $c_end = (isset($range[1]) && is_numeric($range[1])) ? $range[1] : $size;
76
+                    }
77
+
78
+                    $c_end = ($c_end > $end) ? $end : $c_end;
79
+                    if ($c_start > $c_end || $c_start > $size - 1 || $c_end >= $size) {
80
+                        header("Content-Range: bytes $start-$end/$size");
81
+
82
+                        throw new Exception\InvalidRange('invalid offset/limit requested');
83
+                    }
84
+
85
+                    $start = (int) $c_start;
86
+                    $end = (int) $c_end;
87
+                    $length = (int) $end - $start + 1;
88
+                    fseek($stream, $start);
89
+                    header('HTTP/1.1 206 Partial Content');
90
+                    header("Content-Range: bytes $start-$end/$size");
91
+                }
92
+
93
+                header('Content-Length: '.$length);
94
+                $buffer = 1024 * 8;
95
+
96
+                while (!feof($stream) && ($p = ftell($stream)) <= $end) {
97
+                    if ($p + $buffer > $end) {
98
+                        $buffer = $end - $p + 1;
99
+                    }
100
+
101
+                    echo fread($stream, $buffer);
102
+                    flush();
103
+                }
104
+
105
+                fclose($stream);
106
+            });
107 107
     }
108 108
 }
Please login to merge, or discard this patch.