| Conditions | 5 |
| Paths | 5 |
| Total Lines | 22 |
| Code Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 27 | public function save(Http\FileUpload $fileUpload, $path = '', callable $extendStoredFile = NULL) |
||
| 28 | { |
||
| 29 | if (!$fileUpload->isOk()) { |
||
| 30 | throw new FileUploadFailedException($fileUpload->getName(), $fileUpload->getError()); |
||
| 31 | } elseif ($path) { |
||
| 32 | $path = trim($path, '\/') . DIRECTORY_SEPARATOR; |
||
| 33 | } |
||
| 34 | |||
| 35 | do { |
||
| 36 | $relativePath = $path . $this->createUniqueName($fileUpload); |
||
| 37 | } while ($this->driver->isFileExists($relativePath)); |
||
| 38 | |||
| 39 | $storeFile = new Store\File($relativePath, $fileUpload->getName(), $fileUpload->getContentType()); |
||
| 40 | |||
| 41 | if($extendStoredFile !== NULL) { |
||
| 42 | $extendStoredFile($storeFile, $fileUpload); |
||
| 43 | } |
||
| 44 | |||
| 45 | $this->driver->save($fileUpload, $relativePath); |
||
| 46 | |||
| 47 | return $storeFile; |
||
| 48 | } |
||
| 49 | |||
| 65 |