Passed
Push — master ( 617e52...ff4e9f )
by Arthur
35:51
created

ScriptPolicy   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 76
Duplicated Lines 0 %

Test Coverage

Coverage 38.46%

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 76
ccs 5
cts 13
cp 0.3846
rs 10
c 0
b 0
f 0
wmc 6

6 Methods

Rating   Name   Duplication   Size   Complexity  
A update() 0 3 1
A __construct() 0 3 1
A create() 0 3 1
A before() 0 3 1
A delete() 0 3 1
A access() 0 3 1
1
<?php
2
3
namespace Modules\Script\Policies;
4
5
use Foundation\Exceptions\Exception;
6
use Foundation\Policies\OwnershipPolicy;
7
use Modules\Script\Contracts\ScriptServiceContract;
8
use Modules\User\Entities\User;
9
10
class ScriptPolicy extends OwnershipPolicy
11
{
12
    /**
13
     * @var ScriptServiceContract $service
14
     */
15
    protected $service;
16
17
    /**
18
     * ScriptPolicy constructor.
19
     *
20
     * @param ScriptServiceContract $service
21
     */
22 3
    public function __construct(ScriptServiceContract $service)
23
    {
24 3
        $this->service = $service;
25 3
    }
26
27
    /**
28
     * Determine if the given user can access the model.
29
     *
30
     * @param User $user
31
     *
32
     * @throws Exception
33
     *
34
     * @return bool
35
     */
36
    public function access($user, $model): bool
37
    {
38
        return parent::access($user, $model);
39
    }
40
41
    /**
42
     * Determine if the given user can access the model.
43
     *
44
     * @param User $user
45
     *
46
     * @return bool
47
     */
48
    public function create(User $user): bool
49
    {
50
        return parent::create($user);
51
    }
52
53
    /**
54
     * Determine if the given user can update the model.
55
     *
56
     * @param User $user
57
     *
58
     * @throws Exception
59
     *
60
     * @return bool
61
     */
62
    public function update(User $user, $model): bool
63
    {
64
        return parent::update($user, $model);
65
    }
66
67
    /**
68
     * @param User $user
69
     * @param $model
70
     *
71
     * @return bool
72
     */
73
    public function delete(User $user, $model): bool
74
    {
75
        return parent::delete($user, $model);
76
    }
77
78
    /**
79
     * @param User $user
80
     * @param $ability
81
     * @return bool|null
82
     */
83 3
    public function before($user, $ability)
84
    {
85 3
        return parent::before($user, $ability);
86
    }
87
}
88