UsherAuthentication   A
last analyzed

Complexity

Total Complexity 11

Size/Duplication

Total Lines 125
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 11
lcom 2
cbo 2
dl 0
loc 125
rs 10
c 1
b 0
f 0

11 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A login() 0 4 1
A register() 0 4 1
A assignRole() 0 4 1
A logout() 0 4 1
A activate() 0 4 1
A createActivation() 0 4 1
A createReminderCode() 0 4 1
A completeResetPassword() 0 4 1
A hasAccess() 0 4 1
A check() 0 4 1
1
<?php namespace Modules\User\Repositories\Usher;
2
3
use Illuminate\Contracts\Auth\Guard;
4
use Modules\Core\Contracts\Authentication;
5
use Modules\User\Repositories\UserRepository;
6
7
class UsherAuthentication implements Authentication
0 ignored issues
show
Bug introduced by
There is one abstract method id in this class; you could implement it, or declare this class as abstract.
Loading history...
8
{
9
    /**
10
     * @var Guard
11
     */
12
    private $guard;
13
14
    /**
15
     * @var UserRepository
16
     */
17
    private $repository;
18
19
    /**
20
     * @param Guard          $guard
21
     * @param UserRepository $repository
22
     */
23
    public function __construct(Guard $guard, UserRepository $repository)
24
    {
25
        $this->guard = $guard;
26
        $this->repository = $repository;
27
    }
28
29
    /**
30
     * Authenticate a user
31
     * @param  array $credentials
32
     * @param  bool  $remember Remember the user
33
     * @return mixed
34
     */
35
    public function login(array $credentials, $remember = false)
36
    {
37
        return $this->guard->attempt($credentials, $remember);
38
    }
39
40
    /**
41
     * Register a new user.
42
     * @param  array $user
43
     * @return bool
44
     */
45
    public function register(array $user)
46
    {
47
        return $this->repository->create((array) $user);
48
    }
49
50
    /**
51
     * Assign a role to the given user.
52
     * @param  \Modules\User\Repositories\UserRepository $user
53
     * @param  \Modules\User\Repositories\RoleRepository $role
54
     * @return mixed
55
     */
56
    public function assignRole($user, $role)
57
    {
58
        return $user->assignRole($role);
0 ignored issues
show
Bug introduced by
The method assignRole() does not seem to exist on object<Modules\User\Repositories\UserRepository>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
59
    }
60
61
    /**
62
     * Log the user out of the application.
63
     * @return bool
64
     */
65
    public function logout()
66
    {
67
        return $this->guard->logout();
68
    }
69
70
    /**
71
     * Activate the given used id
72
     * @param  int    $userId
73
     * @param  string $code
74
     * @return mixed
75
     */
76
    public function activate($userId, $code)
77
    {
78
        // TODO
79
    }
80
81
    /**
82
     * Create an activation code for the given user
83
     * @param  \Modules\User\Repositories\UserRepository $user
84
     * @return mixed
85
     */
86
    public function createActivation($user)
87
    {
88
        // TODO
89
    }
90
91
    /**
92
     * Create a reminders code for the given user
93
     * @param  \Modules\User\Repositories\UserRepository $user
94
     * @return mixed
95
     */
96
    public function createReminderCode($user)
97
    {
98
        // TODO
99
    }
100
101
    /**
102
     * Completes the reset password process
103
     * @param         $user
104
     * @param  string $code
105
     * @param  string $password
106
     * @return bool
107
     */
108
    public function completeResetPassword($user, $code, $password)
109
    {
110
        // TODO
111
    }
112
113
    /**
114
     * Determines if the current user has access to given permission
115
     * @param $permission
116
     * @return bool
117
     */
118
    public function hasAccess($permission)
119
    {
120
        return $this->guard->user()->hasAccess($permission);
0 ignored issues
show
Bug introduced by
The method hasAccess() does not seem to exist on object<Illuminate\Contracts\Auth\Authenticatable>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
121
    }
122
123
    /**
124
     * Check if the user is logged in
125
     * @return mixed
126
     */
127
    public function check()
128
    {
129
        return $this->guard->user();
130
    }
131
}
132