AuthorizedActions   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
c 1
b 0
f 0
dl 0
loc 19
ccs 9
cts 9
cp 1
rs 10
wmc 4

1 Method

Rating   Name   Duplication   Size   Complexity  
A authorizedActions() 0 17 4
1
<?php
2
3
namespace Devpri\Tinre\Traits;
4
5
use Illuminate\Support\Facades\Auth;
6
7
trait AuthorizedActions
8
{
9 23
    public function authorizedActions(): array
10
    {
11 23
        $authorizedActions = [];
12
13 23
        $user = Auth::user();
14
15 23
        if (! $user) {
16 1
            return $authorizedActions;
17
        }
18
19 22
        foreach ($this->actions as $action) {
20 22
            if ($user->can($action, $this)) {
21 22
                $authorizedActions[] = $action;
22
            }
23
        }
24
25 22
        return $authorizedActions;
26
    }
27
}
28