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

NotAllowedManagerRoute::store()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 2
rs 10
c 0
b 0
f 0
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