CasUserLoginEvent   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 50
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 40%

Importance

Changes 0
Metric Value
dl 50
loc 50
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
namespace Leo108\CAS\Events;
4
5
use Illuminate\Http\Request;
6
use Illuminate\Queue\SerializesModels;
7
use Leo108\CAS\Contracts\Models\UserModel;
8
9 View Code Duplication
class CasUserLoginEvent 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...
10
{
11
    use SerializesModels;
12
13
    /**
14
     * @var Request
15
     */
16
    protected $request;
17
    /**
18
     * @var UserModel
19
     */
20
    protected $user;
21
22
    /**
23
     * CasUserLoginEvent constructor.
24
     * @param Request   $request
25
     * @param UserModel $user
26
     */
27 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...
28
    {
29 2
        $this->request = $request;
30 2
        $this->user    = $user;
31 2
    }
32
33
    /**
34
     * Get the channels the event should be broadcast on.
35
     *
36
     * @return array
37
     */
38
    public function broadcastOn()
39
    {
40
        return [];
41
    }
42
43
    /**
44
     * @return Request
45
     */
46
    public function getRequest()
47
    {
48
        return $this->request;
49
    }
50
51
    /**
52
     * @return UserModel
53
     */
54
    public function getUser()
55
    {
56
        return $this->user;
57
    }
58
}
59