Test Failed
Push — ft/states ( eebc9c )
by Ben
29:42 queued 08:49
created

DeleteManagedModel   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 8
c 1
b 0
f 0
dl 0
loc 15
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 13 2
1
<?php
2
3
namespace Thinktomorrow\Chief\Management\Application;
4
5
use Thinktomorrow\Chief\Audit\Audit;
6
use Thinktomorrow\Chief\States\PageState;
7
use Thinktomorrow\Chief\Management\ManagedModel;
8
use Thinktomorrow\Chief\States\State\StatefulContract;
9
10
class DeleteManagedModel
11
{
12
    public function handle(ManagedModel $model)
13
    {
14
        // For stateful transitions we will apply this deletion as a state
15
        if($model instanceof StatefulContract) {
16
            (new PageState($model))->apply('delete');
17
            $model->save();
0 ignored issues
show
Bug introduced by
The method save() does not exist on Thinktomorrow\Chief\States\State\StatefulContract. It seems like you code against a sub-type of said class. However, the method does not exist in Thinktomorrow\Chief\Test...n\DummyStatefulContract. Are you sure you never get one of those? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

17
            $model->/** @scrutinizer ignore-call */ 
18
                    save();
Loading history...
Bug introduced by
The method save() does not exist on Thinktomorrow\Chief\Management\ManagedModel. Since it exists in all sub-types, consider adding an abstract or default implementation to Thinktomorrow\Chief\Management\ManagedModel. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

17
            $model->/** @scrutinizer ignore-call */ 
18
                    save();
Loading history...
18
        }
19
20
        Audit::activity()
21
            ->performedOn($model)
22
            ->log('deleted');
23
24
        $model->delete();
0 ignored issues
show
Bug introduced by
The method delete() does not exist on Thinktomorrow\Chief\Management\ManagedModel. Since it exists in all sub-types, consider adding an abstract or default implementation to Thinktomorrow\Chief\Management\ManagedModel. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

24
        $model->/** @scrutinizer ignore-call */ 
25
                delete();
Loading history...
25
    }
26
}
27