Passed
Pull Request — master (#53)
by
unknown
05:24
created

InviteCompetitor   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 95
Duplicated Lines 0 %

Test Coverage

Coverage 75.68%

Importance

Changes 0
Metric Value
eloc 39
dl 0
loc 95
ccs 28
cts 37
cp 0.7568
rs 10
c 0
b 0
f 0
wmc 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A toArray() 0 3 1
B toMail() 0 44 7
A via() 0 3 1
A __construct() 0 6 1
1
<?php
2
3
namespace App\Notifications;
4
5
use App\Tournament;
6
use App\User;
7
use Illuminate\Bus\Queueable;
8
use Illuminate\Notifications\Messages\MailMessage;
9
use Illuminate\Notifications\Notification;
10
use Illuminate\Support\Facades\URL;
11
12
class InviteCompetitor extends Notification
13
{
14
    use Queueable;
15
16
    protected $user, $tournament, $code, $category;
17
18
    /**
19
     * Create a new notification instance.
20
     *
21
     * @param User $user
22
     * @param Tournament $tournament
23
     * @param $code
24
     * @param null $category
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $category is correct as it would always require null to be passed?
Loading history...
25
     */
26 1
    public function __construct(User $user, Tournament $tournament, $code, $category = null)
27
    {
28 1
        $this->user = $user;
29 1
        $this->tournament = $tournament;
30 1
        $this->code = $code;
31 1
        $this->category = $category;
32 1
    }
33
34
    /**
35
     * Get the notification's delivery channels.
36
     *
37
     * @param  mixed $notifiable
38
     * @return array
39
     */
40 1
    public function via($notifiable)
0 ignored issues
show
Unused Code introduced by
The parameter $notifiable is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

40
    public function via(/** @scrutinizer ignore-unused */ $notifiable)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
41
    {
42 1
        return ['mail'];
43
    }
44
45
    /**
46
     * Get the mail representation of the notification.
47
     *
48
     * @param  mixed $notifiable
49
     * @return \Illuminate\Notifications\Messages\MailMessage
50
     */
51 1
    public function toMail($notifiable)
0 ignored issues
show
Unused Code introduced by
The parameter $notifiable is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

51
    public function toMail(/** @scrutinizer ignore-unused */ $notifiable)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
52
    {
53
54 1
        $subject = trans('mail.invite_to_tournament') . ": " . $this->tournament->name;
55 1
        $message = (new MailMessage)
56 1
            ->subject($subject)
57 1
            ->greeting(trans('mail.dear_kenshi'))
58 1
            ->line(trans('mail.you_are_invited_to_tournament') . ":" . $this->tournament->name);
59
60 1
        if ($this->tournament->venue_id != null) {
61
            $message
62
                ->line("<strong>" . trans('core.venue') . ': </strong>' . $this->tournament->venue_name)
0 ignored issues
show
Bug introduced by
The property venue_name does not exist on App\Tournament. Did you mean venue?
Loading history...
63
                ->line("<strong>" . trans('core.address') . ': </strong>' . $this->tournament->venue->address);
64
        }
65
        $message
66 1
            ->line(trans("<strong>" . trans('core.eventDateIni') . ': </strong>' . $this->tournament->dateIni))
67 1
            ->line(trans("<strong>" . trans('core.eventDateFin') . ': </strong>' . $this->tournament->dateFin));
68
69 1
        if ($this->tournament->cost != null) {
0 ignored issues
show
Bug introduced by
The property cost does not seem to exist on App\Tournament. Are you sure there is no database migration missing?

Checks if undeclared accessed properties appear in database migrations and if the creating migration is correct.

Loading history...
70
            $message->line("<strong>" . trans('core.cost') . ': </strong>' . $this->tournament->cost);
71
        }
72
73 1
        if ($this->tournament->registerDateLimit != null && $this->tournament->registerDateLimit != '0000-00-00') {
74 1
            $message->line("<strong>" . trans('core.limitDateRegistration') . ': </strong>' . $this->tournament->registerDateLimit);
75
        }
76 1
        if (isset($this->category)) {
77
            $message->line("<strong>" . trans('mail.you_have_been_preregistered') . "</strong>")
78
                ->line('- ' . $this->category);
79
        } else {
80 1
            $message->action(trans('mail.confirm_registration'),
81 1
                URL::action('ChampionshipController@create', [
82 1
                    'tournamentSlug' => $this->tournament->slug,
83 1
                    'token' => $this->code
84
                ]));
85
        }
86 1
        if ($this->user->password != null) {
87
            $message->line(trans('mail.your_connection_data') . ":")
88
                ->line(trans('core.username') . ":" . $this->user->email)
89
                ->line(trans('core.password') . ":" . $this->user->clearPassword);
90
        }
91
92 1
        $message->line(trans('core.thanks'));
93
94 1
        return $message;
95
    }
96
97
98
    /**
99
     * Get the array representation of the notification.
100
     *
101
     * @param  mixed $notifiable
102
     * @return array
103
     */
104
    public function toArray($notifiable)
0 ignored issues
show
Unused Code introduced by
The parameter $notifiable is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

104
    public function toArray(/** @scrutinizer ignore-unused */ $notifiable)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
105
    {
106
        return [
107
            //
108
        ];
109
    }
110
}
111