Passed
Push — master ( cfceb1...4bf73b )
by Koen
09:48
created

Invitation::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Notifications\User;
6
7
use App\Models\User;
8
use App\SPA\UrlGenerator;
9
use Illuminate\Notifications\Messages\MailMessage;
10
use Illuminate\Notifications\Notification;
11
use Illuminate\Support\Facades\Lang;
12
use function config;
13
14
final class Invitation extends Notification
15
{
16
    public string $token;
17
18 3
    public function __construct(string $token)
19
    {
20 3
        $this->token = $token;
21 3
    }
22
23 2
    public function via(): array
24
    {
25 2
        return ['mail'];
26
    }
27
28 2
    public function toMail(User $user): MailMessage
29
    {
30 2
        $url = app(UrlGenerator::class)->to('invitation/accept/' . $this->token, [
31 2
            'email' => $user->getEmailForPasswordReset(),
32
        ]);
33
34 2
        return (new MailMessage())
35 2
            ->subject(Lang::get('Account Invitation Notification'))
36 2
            ->line(Lang::get('You are receiving this email because an account was created for you.'))
37 2
            ->action(Lang::get('Activate account'), $url)
38 2
            ->line(Lang::get('This invitation email will expire in :count hours.', ['count' => config('auth.passwords.user-invitations.expire') / 60]));
39
    }
40
}
41