Permission   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
c 0
b 0
f 0
lcom 1
cbo 3
dl 0
loc 53
ccs 0
cts 6
cp 0
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A firstHashedOrFail() 0 4 1
A getIds() 0 4 1
A hasGroup() 0 4 1
1
<?php namespace Arcanesoft\Auth\Models;
2
3
use Arcanedev\LaravelAuth\Models\Permission as BasePermission;
4
5
/**
6
 * Class     Permission
7
 *
8
 * @package  Arcanesoft\Auth\Models
9
 * @author   ARCANEDEV <[email protected]>
10
 *
11
 * @property  int|null  roles_count
12
 *
13
 * @mixin  \Illuminate\Database\Eloquent\Builder
14
 */
15
class Permission extends BasePermission
16
{
17
    /* -----------------------------------------------------------------
18
     |  Traits
19
     | -----------------------------------------------------------------
20
     */
21
22
    use Presenters\PermissionPresenter;
23
24
    /* -----------------------------------------------------------------
25
     |  Main Methods
26
     | -----------------------------------------------------------------
27
     */
28
29
    /**
30
     * Get a permission from a hashed id or fail if not found.
31
     *
32
     * @param  string  $hashedId
33
     *
34
     * @return self
35
     *
36
     * @throws \Illuminate\Database\Eloquent\ModelNotFoundException
37
     */
38
    public static function firstHashedOrFail($hashedId)
39
    {
40
        return self::withHashedId($hashedId)->firstOrFail();
41
    }
42
43
    /**
44
     * Get the ids of all permissions.
45
     *
46
     * @return \Illuminate\Support\Collection
47
     */
48
    public static function getIds()
49
    {
50
        return self::query()->orderBy('id')->pluck('id');
0 ignored issues
show
Bug introduced by
The method orderBy() does not exist on Illuminate\Database\Eloquent\Builder. Did you maybe mean enforceOrderBy()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
51
    }
52
53
    /* -----------------------------------------------------------------
54
     |  Check Methods
55
     | -----------------------------------------------------------------
56
     */
57
58
    /**
59
     * Check if permission has a group.
60
     *
61
     * @return bool
62
     */
63
    public function hasGroup()
64
    {
65
        return $this->group_id > 0;
66
    }
67
}
68