Completed
Push — master ( 96dd95...b25769 )
by ARCANEDEV
02:59
created

LogViewerPolicy   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 86
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 41.18%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 6
c 2
b 0
f 0
lcom 0
cbo 1
dl 0
loc 86
ccs 7
cts 17
cp 0.4118
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A getPolicies() 0 10 1
A dashboardPolicy() 0 4 1
A listPolicy() 0 4 1
A showPolicy() 0 4 1
A downloadPolicy() 0 4 1
A deletePolicy() 0 4 1
1
<?php namespace Arcanesoft\Foundation\Policies;
2
3
use Arcanesoft\Contracts\Auth\Models\User;
4
5
/**
6
 * Class     LogViewerPolicy
7
 *
8
 * @package  Arcanesoft\Foundation\Policies
9
 * @author   ARCANEDEV <[email protected]>
10
 *
11
 * @todo: Adding the check role (LogViewer manager role)
12
 */
13
class LogViewerPolicy
14
{
15
    /* ------------------------------------------------------------------------------------------------
16
     |  Getters and Setters
17
     | ------------------------------------------------------------------------------------------------
18
     */
19
    /**
20
     * Get the policies.
21
     *
22
     * @return array
23
     */
24 24
    public static function getPolicies()
25
    {
26
        return [
27 24
            'dashboardPolicy' => 'foundation.logviewer.dashboard',
28 18
            'listPolicy'      => 'foundation.logviewer.list',
29 18
            'showPolicy'      => 'foundation.logviewer.show',
30 18
            'downloadPolicy'  => 'foundation.logviewer.download',
31 18
            'deletePolicy'    => 'foundation.logviewer.delete',
32 18
        ];
33
    }
34
35
    /* ------------------------------------------------------------------------------------------------
36
     |  Policies Functions
37
     | ------------------------------------------------------------------------------------------------
38
     */
39
    /**
40
     * Allow to view the LogViewer dashboard.
41
     *
42
     * @param  \Arcanesoft\Contracts\Auth\Models\User  $user
43
     *
44
     * @return bool
45
     */
46
    public function dashboardPolicy(User $user)
47
    {
48
        return $user->may('foundation.logviewer.dashboard');
49
    }
50
51
    /**
52
     * Allow to list all the logs.
53
     *
54
     * @param  \Arcanesoft\Contracts\Auth\Models\User  $user
55
     *
56
     * @return bool
57
     */
58
    public function listPolicy(User $user)
59
    {
60
        return $user->may('foundation.logviewer.list');
61
    }
62
63
    /**
64
     * Allow to display a log.
65
     *
66
     * @param  \Arcanesoft\Contracts\Auth\Models\User  $user
67
     *
68
     * @return bool
69
     */
70
    public function showPolicy(User $user)
71
    {
72
        return $user->may('foundation.logviewer.show');
73
    }
74
75
    /**
76
     * Allow to download a log.
77
     *
78
     * @param  \Arcanesoft\Contracts\Auth\Models\User  $user
79
     *
80
     * @return bool
81
     */
82
    public function downloadPolicy(User $user)
83
    {
84
        return $user->may('foundation.logviewer.download');
85
    }
86
87
    /**
88
     * Allow to delete a log.
89
     *
90
     * @param  \Arcanesoft\Contracts\Auth\Models\User  $user
91
     *
92
     * @return bool
93
     */
94
    public function deletePolicy(User $user)
95
    {
96
        return $user->may('foundation.logviewer.delete');
97
    }
98
}
99