Completed
Push — master ( 59d127...8927df )
by Abdelrahman
09:07 queued 07:21
created

Notifications/RegistrationSuccessNotification.php (1 issue)

Labels
Severity

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

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\Notifications\Notification;
19
use Illuminate\Notifications\Messages\MailMessage;
20
21
class RegistrationSuccessNotification extends Notification
22
{
23
    /**
24
     * Indicates if this is social registration mode or not.
25
     *
26
     * @var bool
27
     */
28
    public $social;
29
30
    /**
31
     * Create a notification instance.
32
     *
33
     * @param bool $social
34
     */
35
    public function __construct($social = false)
36
    {
37
        $this->social = $social;
38
    }
39
40
    /**
41
     * Get the notification's channels.
42
     *
43
     * @param mixed $notifiable
44
     *
45
     * @return array|string
46
     */
47
    public function via($notifiable)
48
    {
49
        return ['mail'];
50
    }
51
52
    /**
53
     * Build the mail representation of the notification.
54
     *
55
     * @return \Illuminate\Notifications\Messages\MailMessage
56
     */
57
    public function toMail()
58
    {
59
        if ($this->social) {
60
            if (config('rinvex.fort.registration.moderated')) {
61
                $phrase = trans('rinvex/fort::frontend/emails.registration.welcome.intro_moderation');
62
            } else {
63
                $phrase = trans('rinvex/fort::frontend/emails.registration.welcome.intro_default');
64
            }
65
        } else {
66
            if (config('rinvex.fort.emailverification.required') && config('rinvex.fort.registration.moderated')) {
67
                $phrase = trans('rinvex/fort::frontend/emails.registration.welcome.intro_verification_moderation');
68
            } elseif (! config('rinvex.fort.emailverification.required') && config('rinvex.fort.registration.moderated')) {
69
                $phrase = trans('rinvex/fort::frontend/emails.registration.welcome.intro_moderation');
70
            } elseif (config('rinvex.fort.emailverification.required') && ! config('rinvex.fort.registration.moderated')) {
71
                $phrase = trans('rinvex/fort::frontend/emails.registration.welcome.intro_verification');
72
            } else {
73
                $phrase = trans('rinvex/fort::frontend/emails.registration.welcome.intro_default');
74
            }
75
        }
76
77
        return (new MailMessage())
78
            ->subject(trans('rinvex/fort::frontend/emails.registration.welcome.subject'))
0 ignored issues
show
It seems like trans('rinvex/fort::fron...ation.welcome.subject') targeting trans() can also be of type object<Illuminate\Contra...Translation\Translator>; however, Illuminate\Notifications...impleMessage::subject() does only seem to accept string, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
79
            ->line($phrase);
80
    }
81
}
82