TouchLastActivity   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 39
wmc 3
lcom 1
cbo 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A handle() 0 6 2
1
<?php namespace Anomaly\UsersModule\User\Listener;
2
3
use Anomaly\UsersModule\User\Contract\UserRepositoryInterface;
4
use Illuminate\Contracts\Auth\Guard;
5
6
/**
7
 * Class TouchLastActivity
8
 *
9
 * @link          http://pyrocms.com/
10
 * @author        PyroCMS, Inc. <[email protected]>
11
 * @author        Ryan Thompson <[email protected]>
12
 */
13
class TouchLastActivity
14
{
15
16
    /**
17
     * The auth utility.
18
     *
19
     * @var Guard
20
     */
21
    protected $auth;
22
23
    /**
24
     * The user repository.
25
     *
26
     * @var UserRepositoryInterface
27
     */
28
    protected $users;
29
30
    /**
31
     * Create a new TouchLastActivity instance.
32
     *
33
     * @param Guard                   $auth
34
     * @param UserRepositoryInterface $users
35
     */
36
    public function __construct(Guard $auth, UserRepositoryInterface $users)
37
    {
38
        $this->auth  = $auth;
39
        $this->users = $users;
40
    }
41
42
    /**
43
     * Handle the event.
44
     */
45
    public function handle()
46
    {
47
        if ($user = $this->auth->user()) {
48
            $this->users->touchLastActivity($user);
49
        }
50
    }
51
}
52