Skip to content

Commit 499aad6

Browse files
Merge pull request #3 from imanghafoori1/analysis-RvYx4M
Apply fixes from StyleCI
2 parents 141b57e + bca1014 commit 499aad6

File tree

2 files changed

+17
-21
lines changed

2 files changed

+17
-21
lines changed

src/StreamServiceProvider.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ public function register()
1717
Response::macro('streamVideoFile', function ($filePath) {
1818
return response()->stream(function () use ($filePath) {
1919
$stream = new VideoStreamer($filePath);
20+
2021
return $stream->start();
2122
});
2223
});

src/VideoStreamer.php

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55
class VideoStreamer
66
{
7-
private $path = "";
7+
private $path = '';
88

9-
private $stream = "";
9+
private $stream = '';
1010

1111
private $buffer = 102400;
1212

@@ -16,7 +16,7 @@ class VideoStreamer
1616

1717
private $size = 0;
1818

19-
private $mime = "";
19+
private $mime = '';
2020

2121
public function __construct($filePath = '')
2222
{
@@ -26,8 +26,7 @@ public function __construct($filePath = '')
2626
}
2727

2828
/**
29-
* Open stream
30-
*
29+
* Open stream.
3130
*/
3231
private function open()
3332
{
@@ -37,23 +36,22 @@ private function open()
3736
}
3837

3938
/**
40-
* Set proper header to serve the video content
41-
*
39+
* Set proper header to serve the video content.
4240
*/
4341
private function setHeader()
4442
{
4543
ob_get_clean();
46-
header("Content-Type: " . $this->mime);
47-
header("Cache-Control: max-age=2592000, public");
48-
header("Expires: " . gmdate('D, d M Y H:i:s', time() + 2592000) . ' GMT');
49-
header("Last-Modified: " . gmdate('D, d M Y H:i:s', @filemtime($this->path)) . ' GMT');
44+
header('Content-Type: '.$this->mime);
45+
header('Cache-Control: max-age=2592000, public');
46+
header('Expires: '.gmdate('D, d M Y H:i:s', time() + 2592000).' GMT');
47+
header('Last-Modified: '.gmdate('D, d M Y H:i:s', @filemtime($this->path)).' GMT');
5048
$this->start = 0;
5149
$this->size = filesize($this->path);
5250
$this->end = $this->size - 1;
53-
header("Accept-Ranges: 0-" . $this->end);
51+
header('Accept-Ranges: 0-'.$this->end);
5452

5553
if (! isset($_SERVER['HTTP_RANGE'])) {
56-
header("Content-Length: " . $this->size);
54+
header('Content-Length: '.$this->size);
5755

5856
return;
5957
}
@@ -89,13 +87,12 @@ private function setHeader()
8987
$length = $this->end - $this->start + 1;
9088
fseek($this->stream, $this->start);
9189
header('HTTP/1.1 206 Partial Content');
92-
header("Content-Length: " . $length);
93-
header("Content-Range: bytes $this->start-$this->end/" . $this->size);
90+
header('Content-Length: '.$length);
91+
header("Content-Range: bytes $this->start-$this->end/".$this->size);
9492
}
9593

9694
/**
97-
* close curretly opened stream
98-
*
95+
* close curretly opened stream.
9996
*/
10097
private function end()
10198
{
@@ -105,8 +102,7 @@ private function end()
105102
}
106103

107104
/**
108-
* perform the streaming of calculated range
109-
*
105+
* perform the streaming of calculated range.
110106
*/
111107
private function stream()
112108
{
@@ -125,8 +121,7 @@ private function stream()
125121
}
126122

127123
/**
128-
* Start streaming video content
129-
*
124+
* Start streaming video content.
130125
*/
131126
public function start()
132127
{

0 commit comments

Comments
 (0)