Passed
Push — master ( 72cb54...ce8977 )
by Philippe
02:38 queued 14s
created

NotAllowedManagerRoute   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Test Coverage

Coverage 37.5%

Importance

Changes 0
Metric Value
wmc 8
eloc 9
c 0
b 0
f 0
dl 0
loc 40
ccs 6
cts 16
cp 0.375
rs 10

8 Methods

Rating   Name   Duplication   Size   Complexity  
A index() 0 3 1
A notAllowedPermission() 0 3 1
A notAllowedVerb() 0 3 1
A delete() 0 3 1
A edit() 0 3 1
A update() 0 3 1
A store() 0 3 1
A create() 0 3 1
1
<?php
2
3
namespace Thinktomorrow\Chief\Management\Exceptions;
4
5
use Illuminate\Auth\Access\AuthorizationException;
6
use Thinktomorrow\Chief\Management\Manager;
7
8
class NotAllowedManagerRoute extends AuthorizationException
9
{
10
    public static function index(Manager $manager)
11
    {
12
        return static::notAllowedVerb('index', $manager);
13
    }
14
15 2
    public static function create(Manager $manager)
16
    {
17 2
        return static::notAllowedVerb('create', $manager);
18
    }
19
20
    public static function store(Manager $manager)
21
    {
22
        return static::notAllowedVerb('store', $manager);
23
    }
24
25
    public static function edit(Manager $manager)
26
    {
27
        return static::notAllowedVerb('edit', $manager);
28
    }
29
30
    public static function update(Manager $manager)
31
    {
32
        return static::notAllowedVerb('update', $manager);
33
    }
34
35
    public static function delete(Manager $manager)
36
    {
37
        return static::notAllowedVerb('delete', $manager);
38
    }
39
40 5
    public static function notAllowedVerb($verb, Manager $manager)
41
    {
42 5
        throw new static('Not allowed to '.$verb.' a model. '.ucfirst($verb).' route is not allowed by the ' . $manager->details()->key.' manager.');
0 ignored issues
show
Bug Best Practice introduced by
The property key does not exist on Thinktomorrow\Chief\Management\Details\Details. Since you implemented __get, consider adding a @property annotation.
Loading history...
43
    }
44
45 1
    public static function notAllowedPermission($permission, Manager $manager)
46
    {
47 1
        throw new static('Not allowed permission for '.$permission.' on a model as managed by the ' . $manager->details()->key.' manager.');
0 ignored issues
show
Bug Best Practice introduced by
The property key does not exist on Thinktomorrow\Chief\Management\Details\Details. Since you implemented __get, consider adding a @property annotation.
Loading history...
48
    }
49
}
50