| Conditions | 2 |
| Paths | 2 |
| Total Lines | 17 |
| Code Lines | 6 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 6 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 17 | public function download( |
||
| 18 | string $path, |
||
| 19 | Request $request, |
||
|
|
|||
| 20 | TranslatorInterface $translator, |
||
| 21 | ParameterBagInterface $params |
||
| 22 | ) { |
||
| 23 | |||
| 24 | $pathToFile = $this->get('kernel')->getProjectDir().'/media/'.substr(str_replace('..', '', $path), strlen('media/')); |
||
| 25 | |||
| 26 | if (!file_exists($pathToFile)) { |
||
| 27 | throw $this->createNotFoundException('The media does not exist...'); |
||
| 28 | } |
||
| 29 | |||
| 30 | $response = new BinaryFileResponse($pathToFile); |
||
| 31 | $response->setContentDisposition(ResponseHeaderBag::DISPOSITION_ATTACHMENT); |
||
| 32 | |||
| 33 | return $response; |
||
| 34 | |||
| 37 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.