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

DeleteAsset   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
dl 0
loc 20
ccs 5
cts 5
cp 1
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A deleteAll() 0 3 1
A delete() 0 3 1
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