| Conditions | 5 |
| Paths | 4 |
| Total Lines | 16 |
| Code Lines | 8 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 9 |
| CRAP Score | 5 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 33 | 5 | public static function remove($id) |
|
| 34 | { |
||
| 35 | 5 | if (! $id) { |
|
| 36 | 1 | return false; |
|
| 37 | } |
||
| 38 | |||
| 39 | 4 | $asset = Asset::find($id)->first(); |
|
| 40 | 4 | $media = $asset->media; |
|
| 41 | |||
| 42 | 4 | foreach ($media as $file) { |
|
| 43 | 4 | if (! is_file(public_path($file->getUrl())) || ! is_writable(public_path($file->getUrl()))) { |
|
| 44 | 4 | return; |
|
| 45 | } |
||
| 46 | } |
||
| 47 | |||
| 48 | 4 | $asset->delete(); |
|
| 49 | 4 | } |
|
| 60 |