We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
| Total Complexity | 6 |
| Total Lines | 50 |
| Duplicated Lines | 0 % |
| Changes | 2 | ||
| Bugs | 1 | Features | 0 |
| 1 | <?php |
||
| 8 | trait HandleFileNaming |
||
| 9 | { |
||
| 10 | /** |
||
| 11 | * Developer provided filename. |
||
| 12 | * |
||
| 13 | * @var null|string|\Closure |
||
| 14 | */ |
||
| 15 | public $fileName = null; |
||
| 16 | |||
| 17 | /** |
||
| 18 | * The file name generator. |
||
| 19 | * |
||
| 20 | * @var FileNameGeneratorInterface |
||
| 21 | */ |
||
| 22 | public $fileNameGenerator; |
||
| 23 | |||
| 24 | /** |
||
| 25 | * Returns the file generator class. |
||
| 26 | * |
||
| 27 | * @param null|string $fileNameGenerator |
||
| 28 | * @return void |
||
| 29 | */ |
||
| 30 | private function setFileNameGenerator($fileNameGenerator) |
||
| 31 | { |
||
| 32 | $fileGeneratorClass = $fileNameGenerator ?? config('backpack.crud.file_name_generator'); |
||
| 33 | |||
| 34 | if (! class_exists($fileGeneratorClass)) { |
||
| 35 | throw new \Exception("The file name generator class [{$fileGeneratorClass}] does not exist."); |
||
| 36 | } |
||
| 37 | |||
| 38 | if (! class_implements($fileGeneratorClass, FileNameGeneratorInterface::class)) { |
||
|
|
|||
| 39 | throw new \Exception("The file name generator class [{$fileGeneratorClass}] must implement the [".FileNameGeneratorInterface::class.'] interface.'); |
||
| 40 | } |
||
| 41 | |||
| 42 | $this->fileNameGenerator = new $fileGeneratorClass(); |
||
| 43 | } |
||
| 44 | |||
| 45 | /** |
||
| 46 | * Return the file name. |
||
| 47 | * |
||
| 48 | * @param string|UploadedFile $file |
||
| 49 | * @return string |
||
| 50 | */ |
||
| 51 | public function getFileName($file) |
||
| 58 | } |
||
| 59 | } |
||
| 60 |