ForUser   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A findIdUsing() 0 5 1
A findId() 0 7 2
1
<?php
2
3
namespace NovaThinKit\Nova\Actions;
4
5
use Illuminate\Database\Eloquent\Model;
6
7
trait ForUser
8
{
9
    public ?\Closure $findIdUsing = null;
10
11 4
    protected function findId(Model $model)
12
    {
13 4
        if (is_callable($this->findIdUsing)) {
14 1
            return call_user_func_array($this->findIdUsing, [$model]);
0 ignored issues
show
Bug introduced by
It seems like $this->findIdUsing can also be of type null; however, parameter $callback of call_user_func_array() does only seem to accept callable, 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

14
            return call_user_func_array(/** @scrutinizer ignore-type */ $this->findIdUsing, [$model]);
Loading history...
15
        }
16
17 3
        return $model->getKey();
18
    }
19
20 8
    public function findIdUsing(?\Closure $findIdUsing): static
21
    {
22 8
        $this->findIdUsing = $findIdUsing;
23
24 8
        return $this;
25
    }
26
}
27