SoftDeleteTrait   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Test Coverage

Coverage 50%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A isDeleted() 0 4 1
A softDelete() 0 4 1
1
<?php
2
namespace App\Model;
3
4
trait SoftDeleteTrait
5
{
6
    protected $softDeleteField = 'is_deleted';
7
8
    protected $softDeleteValue = 1;
9
10
    public function softDelete()
11
    {
12
        return $this->updateAttributes([
0 ignored issues
show
Bug introduced by
It seems like updateAttributes() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

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

12
        return $this->/** @scrutinizer ignore-call */ updateAttributes([
Loading history...
13
            $this->softDeleteField => $this->softDeleteValue,
14
        ]);
15
    }
16
17
    /**
18
     * @return bool
19
     */
20 1
    public function isDeleted(): bool
21
    {
22 1
        $field = $this->softDeleteField;
23 1
        return $this->$field == $this->softDeleteValue;
24
    }
25
}
26