Passed
Push — 0.6 ( fa70f4...7db85c )
by Philippe
06:36
created

DeleteAsset::deleteAll()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
3
namespace Thinktomorrow\AssetLibrary\Models\Application;
4
5
use Thinktomorrow\AssetLibrary\Models\Asset;
6
use Thinktomorrow\AssetLibrary\Interfaces\HasAsset;
7
use Thinktomorrow\AssetLibrary\Models\AssetLibrary;
8
9
class DeleteAsset
10
{
11
    /**
12
     * Removes an asset completely.
13
     *
14
     * @param $ids
15
     */
16 1
    public function delete($ids): void
17
    {
18 1
        AssetLibrary::removeByIds($ids);
19 1
    }
20
21
    /**
22
     * Removes all assets completely.
23
     *
24
     * @param $ids
25
     */
26 1
    public function deleteAll(HasAsset $model): void
27
    {
28 1
        $model->assetRelation->each->delete();
0 ignored issues
show
Bug introduced by
Accessing assetRelation on the interface Thinktomorrow\AssetLibrary\Interfaces\HasAsset suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
29 1
    }
30
}
31