| Conditions | 3 |
| Paths | 2 |
| Total Lines | 10 |
| Code Lines | 4 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 5 |
| CRAP Score | 3 |
| Changes | 0 | ||
| 1 | <?php |
||
| 25 | 6 | public function setSong(Song $song): void |
|
| 26 | { |
||
| 27 | 6 | $this->song = $song; |
|
| 28 | |||
| 29 | 6 | abort_unless($this->song->s3_params || file_exists($this->song->path), 404); |
|
| 30 | |||
| 31 | // Hard code the content type instead of relying on PHP's fileinfo() |
||
| 32 | // or even Symfony's MIMETypeGuesser, since they appear to be wrong sometimes. |
||
| 33 | 6 | if (!$this->song->s3_params) { |
|
| 34 | 5 | $this->contentType = 'audio/'.pathinfo($this->song->path, PATHINFO_EXTENSION); |
|
| 35 | } |
||
| 38 |
If you suppress an error, we recommend checking for the error condition explicitly: