Passed
Push — develop ( 97f65e...d0561f )
by Enea
03:00
created

GrantableObserver   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 7
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
dl 0
loc 7
ccs 0
cts 5
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A saving() 0 5 2
1
<?php
2
/**
3
 * Created on 22/03/18 by enea dhack.
4
 */
5
6
namespace Enea\Authorization\Observers;
7
8
use Enea\Authorization\Support\Determiner;
9
use Illuminate\Database\Eloquent\Model;
10
11
class GrantableObserver
12
{
13
    public function saving(Model $model): void
14
    {
15
        if (Determiner::transformSecretNameToKebabCase()) {
16
            $name = $model->getAttribute('display_name');
17
            $model->setAttribute('secret_name', kebab_case($name));
0 ignored issues
show
Bug introduced by
It seems like $name can also be of type Illuminate\Database\Eloq...uent\Relations\Relation and Illuminate\Database\Eloquent\Relations\Relation; however, parameter $value of kebab_case() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

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

17
            $model->setAttribute('secret_name', kebab_case(/** @scrutinizer ignore-type */ $name));
Loading history...
18
        }
19
    }
20
}
21