Completed
Push — master ( f06f41...6c4f3d )
by Ryan
02:40
created

UserPendingActivation   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 47
Duplicated Lines 21.28 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A via() 0 4 1
A toMail() 10 10 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 Illuminate\Notifications\Notifiable;
4
use Illuminate\Notifications\Notification;
5
use Illuminate\Notifications\Messages\SlackMessage;
6
use Anomaly\UsersModule\User\Contract\UserInterface;
7
use Anomaly\Streams\Platform\Notification\Message\MailMessage;
8
9
class UserPendingActivation extends Notification
10
{
11
    /**
12
     * The user pending activation.
13
     *
14
     * @var UserInterface
15
     */
16
    public $user;
17
18
    /**
19
     * Create a new UserPendingActivation instance.
20
     *
21
     * @param UserInterface $user
22
     */
23
    public function __construct(UserInterface $user)
24
    {
25
        $this->user = $user;
26
    }
27
28
    /**
29
     * Get the notification's delivery channels.
30
     *
31
     * @param  UserInterface $notifiable
32
     * @return array
33
     */
34
    public function via(UserInterface $notifiable)
35
    {
36
        return ['mail'];
37
    }
38
39
    /**
40
     * Return the mail message.
41
     *
42
     * @param  UserInterface $notifiable
43
     * @return MailMessage
44
     */
45 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...
46
    {
47
        $data = $this->user->toArray();
48
49
        return (new MailMessage())
50
            ->view('anomaly.module.users::notifications.user_pending_activation')
51
            ->subject(trans('anomaly.module.users::notification.user_pending_activation.subject', $data))
52
            ->line(trans('anomaly.module.users::notification.user_pending_activation.instructions', $data))
53
            ->action(trans('anomaly.module.users::notification.user_pending_activation.button', $data), url('admin/users/edit/' . $this->user->getId()));
54
    }
55
}
56