| Conditions | 3 |
| Paths | 4 |
| Total Lines | 19 |
| Code Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 29 | public function uploadGpxFile(File $gpxFile): string |
||
| 30 | { |
||
| 31 | if ($gpxFile instanceof UploadedFile) { |
||
| 32 | $originalFilename = pathinfo($gpxFile->getClientOriginalName(), PATHINFO_FILENAME); |
||
| 33 | } else { |
||
| 34 | $originalFilename = $gpxFile->getFilename(); |
||
| 35 | } |
||
| 36 | $safeFilename = $this->slugger->slug(/** @scrutinizer ignore-type */ $originalFilename); |
||
| 37 | $newFilename = $safeFilename . '-' . uniqid() . '.' . $gpxFile->guessExtension(); |
||
| 38 | try { |
||
| 39 | $gpxFile->move( |
||
| 40 | $this->gpxDirectory, |
||
| 41 | $newFilename |
||
| 42 | ); |
||
| 43 | } |
||
| 44 | catch (FileException $e) { |
||
| 45 | throw new HttpException(500, "Failed finishing GPX upload: " . $e->getMessage()); |
||
| 46 | } |
||
| 47 | return $newFilename; |
||
| 48 | } |
||
| 49 | } |