Conditions | 6 |
Paths | 5 |
Total Lines | 23 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Tests | 9 |
CRAP Score | 6.0359 |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
31 | public function remove($id) |
||
32 | 5 | { |
|
33 | 1 | if (! $id) { |
|
34 | return false; |
||
35 | } |
||
36 | 4 | ||
37 | if (! $asset = Asset::find($id)) { |
||
38 | return false; |
||
39 | } |
||
40 | 4 | ||
41 | 4 | $media = $asset->media; |
|
42 | 4 | ||
43 | 4 | /** @var Media $file */ |
|
44 | foreach ($media as $file) { |
||
45 | |||
46 | $file_path = $file->getPath(); |
||
47 | 3 | ||
48 | 3 | if (! is_file($file_path) || ! is_writable($file_path)) { |
|
49 | throw new FileNotAccessibleException(); |
||
50 | } |
||
51 | } |
||
52 | |||
53 | $asset->delete(); |
||
54 | } |
||
66 |