Completed
Push — master ( 453b67...10e484 )
by Abdelrahman
11:57
created

RegistrationSuccessNotification   A

Complexity

Total Complexity 11

Size/Duplication

Total Lines 63
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 63
rs 10
c 1
b 0
f 0
wmc 11
lcom 1
cbo 2

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A via() 0 4 1
C toMail() 0 24 9
1
<?php
2
3
/*
4
 * NOTICE OF LICENSE
5
 *
6
 * Part of the Rinvex Fort Package.
7
 *
8
 * This source file is subject to The MIT License (MIT)
9
 * that is bundled with this package in the LICENSE file.
10
 *
11
 * Package: Rinvex Fort Package
12
 * License: The MIT License (MIT)
13
 * Link:    https://rinvex.com
14
 */
15
16
namespace Rinvex\Fort\Notifications;
17
18
use Illuminate\Support\Facades\Lang;
19
use Illuminate\Notifications\Notification;
20
use Illuminate\Notifications\Messages\MailMessage;
21
22
class RegistrationSuccessNotification extends Notification
23
{
24
    /**
25
     * Indicates if this is social registration mode or not.
26
     *
27
     * @var bool
28
     */
29
    public $social;
30
31
    /**
32
     * Create a notification instance.
33
     *
34
     * @param bool $social
35
     *
36
     * @return void
0 ignored issues
show
Comprehensibility Best Practice introduced by
Adding a @return annotation to constructors is generally not recommended as a constructor does not have a meaningful return value.

Adding a @return annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.

Please refer to the PHP core documentation on constructors.

Loading history...
37
     */
38
    public function __construct($social = false)
39
    {
40
        $this->social = $social;
41
    }
42
43
    /**
44
     * Get the notification's channels.
45
     *
46
     * @param mixed $notifiable
47
     *
48
     * @return array|string
49
     */
50
    public function via($notifiable)
0 ignored issues
show
Unused Code introduced by
The parameter $notifiable is not used and could be removed.

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

Loading history...
51
    {
52
        return ['mail'];
53
    }
54
55
    /**
56
     * Build the mail representation of the notification.
57
     *
58
     * @return \Illuminate\Notifications\Messages\MailMessage
59
     */
60
    public function toMail()
61
    {
62
        if ($this->social) {
63
            if (config('rinvex.fort.registration.moderated')) {
64
                $phrase = Lang::get('rinvex.fort::email.registration.welcome.intro_moderation');
65
            } else {
66
                $phrase = Lang::get('rinvex.fort::email.registration.welcome.intro_default');
67
            }
68
        } else {
69
            if (config('rinvex.fort.verification.required') && config('rinvex.fort.registration.moderated')) {
70
                $phrase = Lang::get('rinvex.fort::email.registration.welcome.intro_verification_moderation');
71
            } elseif (! config('rinvex.fort.verification.required') && config('rinvex.fort.registration.moderated')) {
72
                $phrase = Lang::get('rinvex.fort::email.registration.welcome.intro_moderation');
73
            } elseif (config('rinvex.fort.verification.required') && ! config('rinvex.fort.registration.moderated')) {
74
                $phrase = Lang::get('rinvex.fort::email.registration.welcome.intro_verification');
75
            } else {
76
                $phrase = Lang::get('rinvex.fort::email.registration.welcome.intro_default');
77
            }
78
        }
79
80
        return (new MailMessage)
81
            ->subject(Lang::get('rinvex.fort::email.registration.welcome.subject'))
82
            ->line($phrase);
83
    }
84
}
85