| Conditions | 1 |
| Paths | 1 |
| Total Lines | 15 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 9 |
| CRAP Score | 1 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 19 | 1 | public function stream( |
|
| 20 | ResponseInterface $response, |
||
| 21 | SongInterface $song, |
||
| 22 | ): ResponseInterface { |
||
| 23 | 1 | $size = $song->getFileSize(); |
|
| 24 | |||
| 25 | return $response |
||
| 26 | 1 | ->withHeader('Content-Type', (string) $song->getMimeType()) |
|
| 27 | 1 | ->withHeader('Content-Disposition', sprintf('attachment; filename=song%d.mp3', $song->getId())) |
|
| 28 | 1 | ->withHeader('Content-Length', (string) $size) |
|
| 29 | 1 | ->withHeader('Cache-Control', 'no-cache') |
|
| 30 | 1 | ->withHeader('Content-Range', 'bytes 0-'.$size) |
|
| 31 | //->withHeader('Accept-Ranges', 'bytes') @todo add seek |
||
| 32 | 1 | ->withBody( |
|
| 33 | 1 | $this->createStream($song) |
|
| 34 | ); |
||
| 42 |