| Total Complexity | 11 |
| Total Lines | 49 |
| Duplicated Lines | 0 % |
| Coverage | 95.24% |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 9 | class DeleteAsset |
||
| 10 | { |
||
| 11 | /** |
||
| 12 | * Removes an asset completely. |
||
| 13 | * |
||
| 14 | * @param $ids |
||
| 15 | */ |
||
| 16 | 5 | public function delete($ids): void |
|
| 27 | } |
||
| 28 | 4 | } |
|
| 29 | |||
| 30 | 5 | public function remove($id) |
|
| 31 | { |
||
| 32 | 5 | if (! $id) { |
|
| 33 | 1 | return false; |
|
| 34 | } |
||
| 35 | |||
| 36 | 4 | if (! $asset = Asset::find($id)) { |
|
| 37 | return false; |
||
| 38 | } |
||
| 39 | |||
| 40 | 4 | $media = $asset->media; |
|
| 41 | 4 | foreach ($media as $file) { |
|
| 42 | 4 | if (! is_file(public_path($file->getUrl())) || ! is_writable(public_path($file->getUrl()))) { |
|
| 43 | 4 | throw new FileNotAccessibleException(); |
|
| 44 | } |
||
| 45 | } |
||
| 46 | |||
| 47 | 3 | $asset->delete(); |
|
| 48 | 3 | } |
|
| 49 | |||
| 50 | /** |
||
| 51 | * Removes all assets completely. |
||
| 52 | * |
||
| 53 | * @param $ids |
||
| 54 | */ |
||
| 55 | 1 | public function deleteAll(HasAsset $model): void |
|
| 58 | 1 | } |
|
| 59 | } |
||
| 60 |