CasUserLogoutEvent   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 49
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 40%

Importance

Changes 0
Metric Value
dl 49
loc 49
ccs 4
cts 10
cp 0.4
rs 10
c 0
b 0
f 0
wmc 4
lcom 0
cbo 2

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 5 5 1
A broadcastOn() 4 4 1
A getRequest() 4 4 1
A getUser() 4 4 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: leo108
5
 * Date: 16/9/18
6
 * Time: 11:28
7
 */
8
9
namespace Leo108\CAS\Events;
10
11
use Illuminate\Http\Request;
12
use Illuminate\Queue\SerializesModels;
13
use Leo108\CAS\Contracts\Models\UserModel;
14
15 View Code Duplication
class CasUserLogoutEvent extends Event
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
16
{
17
    use SerializesModels;
18
    /**
19
     * @var Request
20
     */
21
    protected $request;
22
    /**
23
     * @var UserModel
24
     */
25
    protected $user;
26
27
    /**
28
     * CasUserLoginEvent constructor.
29
     * @param Request   $request
30
     * @param UserModel $user
31
     */
32 2
    public function __construct(Request $request, UserModel $user)
0 ignored issues
show
Bug introduced by
You have injected the Request via parameter $request. This is generally not recommended as there might be multiple instances during a request cycle (f.e. when using sub-requests). Instead, it is recommended to inject the RequestStack and retrieve the current request each time you need it via getCurrentRequest().
Loading history...
33
    {
34 2
        $this->request = $request;
35 2
        $this->user    = $user;
36 2
    }
37
38
    /**
39
     * Get the channels the event should be broadcast on.
40
     *
41
     * @return array
42
     */
43
    public function broadcastOn()
44
    {
45
        return [];
46
    }
47
48
    /**
49
     * @return Request
50
     */
51
    public function getRequest()
52
    {
53
        return $this->request;
54
    }
55
56
    /**
57
     * @return UserModel
58
     */
59
    public function getUser()
60
    {
61
        return $this->user;
62
    }
63
}
64