SentryRoleRepository   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 67
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0
Metric Value
wmc 6
lcom 0
cbo 0
dl 0
loc 67
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A all() 0 4 1
A create() 0 5 1
A find() 0 4 1
A update() 0 7 1
A delete() 0 6 1
A findByName() 0 4 1
1
<?php namespace Modules\User\Repositories\Sentry;
2
3
use Cartalyst\Sentry\Facades\Laravel\Sentry;
4
use Modules\User\Repositories\RoleRepository;
5
6
class SentryRoleRepository implements RoleRepository
7
{
8
    /**
9
     * Return all the roles
10
     * @return mixed
11
     */
12
    public function all()
13
    {
14
        return Sentry::findAllGroups();
15
    }
16
17
    /**
18
     * Create a role resource
19
     * @return mixed
20
     */
21
    public function create($data)
22
    {
23
        unset($data['slug']);
24
        Sentry::createGroup($data);
25
    }
26
27
    /**
28
     * Find a role by its id
29
     * @param $id
30
     * @return mixed
31
     */
32
    public function find($id)
33
    {
34
        return Sentry::findGroupById($id);
35
    }
36
37
    /**
38
     * Update a role
39
     * @param $id
40
     * @param $data
41
     * @return mixed
42
     */
43
    public function update($id, $data)
44
    {
45
        unset($data['slug']);
46
        $role = Sentry::findGroupById($id);
47
48
        $role->update($data);
49
    }
50
51
    /**
52
     * Delete a role
53
     * @param $id
54
     * @return mixed
55
     */
56
    public function delete($id)
57
    {
58
        $role = Sentry::findGroupById($id);
59
60
        return $role->delete();
61
    }
62
63
    /**
64
     * Find a role by its name
65
     * @param  string $name
66
     * @return mixed
67
     */
68
    public function findByName($name)
69
    {
70
        return Sentry::findGroupByName($name);
71
    }
72
}
73