UserPendingActivation   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 53
Duplicated Lines 18.87 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A via() 0 4 1
A toMail() 10 13 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 namespace Anomaly\UsersModule\User\Notification;
2
3
use Anomaly\Streams\Platform\Notification\Message\MailMessage;
4
use Anomaly\UsersModule\User\Contract\UserInterface;
5
use Illuminate\Bus\Queueable;
6
use Illuminate\Contracts\Queue\ShouldQueue;
7
use Illuminate\Notifications\Notification;
8
9
/**
10
 * Class UserPendingActivation
11
 *
12
 * @link   http://pyrocms.com/
13
 * @author PyroCMS, Inc. <[email protected]>
14
 * @author Ryan Thompson <[email protected]>
15
 */
16
class UserPendingActivation extends Notification implements ShouldQueue
17
{
18
19
    use Queueable;
20
21
    /**
22
     * The user pending activation.
23
     *
24
     * @var UserInterface
25
     */
26
    public $user;
27
28
    /**
29
     * Create a new UserPendingActivation instance.
30
     *
31
     * @param UserInterface $user
32
     */
33
    public function __construct(UserInterface $user)
34
    {
35
        $this->user = $user;
36
    }
37
38
    /**
39
     * Get the notification's delivery channels.
40
     *
41
     * @param  UserInterface $notifiable
42
     * @return array
43
     */
44
    public function via(UserInterface $notifiable)
45
    {
46
        return ['mail'];
47
    }
48
49
    /**
50
     * Return the mail message.
51
     *
52
     * @param  UserInterface $notifiable
53
     * @return MailMessage
54
     */
55 View Code Duplication
    public function toMail(UserInterface $notifiable)
0 ignored issues
show
Duplication introduced by
This method 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...
56
    {
57
        $data = $this->user->toArray();
58
59
        return (new MailMessage())
60
            ->view('anomaly.module.users::notifications.user_pending_activation')
61
            ->subject(trans('anomaly.module.users::notification.user_pending_activation.subject', $data))
62
            ->line(trans('anomaly.module.users::notification.user_pending_activation.instructions', $data))
63
            ->action(
64
                trans('anomaly.module.users::notification.user_pending_activation.button', $data),
65
                url('admin/users/edit/' . $this->user->getId())
66
            );
67
    }
68
}
69