Passed
Push — analysis-z94Pol ( 0fb1cd )
by Philippe
33:58 queued 22:51
created

Nomadic   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 10
Duplicated Lines 0 %

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A nomadicCan() 0 8 5
1
<?php
2
3
namespace Thinktomorrow\Chief\Management;
4
5
use Thinktomorrow\Chief\Management\Exceptions\NotAllowedManagerRoute;
6
7
trait Nomadic
8
{
9
    public function nomadicCan($verb)
10
    {
11
        if (in_array($verb, ['create', 'store', 'delete']) && ! auth()->guard('chief')->user()->hasRole('developer')) {
0 ignored issues
show
Bug introduced by
The method hasRole() does not exist on Illuminate\Contracts\Auth\Authenticatable. It seems like you code against a sub-type of Illuminate\Contracts\Auth\Authenticatable such as Illuminate\Foundation\Auth\User. ( Ignorable by Annotation )

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

11
        if (in_array($verb, ['create', 'store', 'delete']) && ! auth()->guard('chief')->user()->/** @scrutinizer ignore-call */ hasRole('developer')) {
Loading history...
12
            throw NotAllowedManagerRoute::notAllowedVerb($verb, $this);
0 ignored issues
show
Bug introduced by
$this of type Thinktomorrow\Chief\Management\Nomadic is incompatible with the type Thinktomorrow\Chief\Management\Manager expected by parameter $manager of Thinktomorrow\Chief\Mana...Route::notAllowedVerb(). ( Ignorable by Annotation )

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

12
            throw NotAllowedManagerRoute::notAllowedVerb($verb, /** @scrutinizer ignore-type */ $this);
Loading history...
13
        }
14
15
        if (in_array($verb, ['create', 'store']) && $this->indexCollection()->count() > 0) {
0 ignored issues
show
Bug introduced by
It seems like indexCollection() 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

15
        if (in_array($verb, ['create', 'store']) && $this->/** @scrutinizer ignore-call */ indexCollection()->count() > 0) {
Loading history...
16
            throw NotAllowedManagerRoute::create($this);
0 ignored issues
show
Bug introduced by
$this of type Thinktomorrow\Chief\Management\Nomadic is incompatible with the type Thinktomorrow\Chief\Management\Manager expected by parameter $manager of Thinktomorrow\Chief\Mana...dManagerRoute::create(). ( Ignorable by Annotation )

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

16
            throw NotAllowedManagerRoute::create(/** @scrutinizer ignore-type */ $this);
Loading history...
17
        }
18
    }
19
}
20