| Conditions | 8 |
| Paths | 16 |
| Total Lines | 25 |
| Code Lines | 14 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 20 | public function attach(mixed $file, ?UploadedFile $cover = null): bool |
||
| 21 | { |
||
| 22 | $fileIsAttachable = (file_has_value($file) or $file == LARUPLOAD_NULL); |
||
| 23 | $coverIsAttachable = (file_has_value($cover) or $cover == null); |
||
| 24 | |||
| 25 | if ($fileIsAttachable and $coverIsAttachable) { |
||
| 26 | file_is_valid($file, $this->name, 'file'); |
||
| 27 | file_is_valid($cover, $this->name, 'cover'); |
||
| 28 | |||
| 29 | $this->file = $file; |
||
|
|
|||
| 30 | $this->uploaded = false; |
||
| 31 | |||
| 32 | if ($file != LARUPLOAD_NULL) { |
||
| 33 | $this->cover = $cover; |
||
| 34 | $this->type = GuessLaruploadFileTypeAction::make($file)->calc(); |
||
| 35 | |||
| 36 | if ($this->type === LaruploadFileType::IMAGE && $this->optimizeImage) { |
||
| 37 | $this->file = OptimizeImageAction::make($file)->process(); |
||
| 38 | } |
||
| 39 | } |
||
| 40 | |||
| 41 | return true; |
||
| 42 | } |
||
| 43 | |||
| 44 | return false; |
||
| 45 | } |
||
| 52 |