ServiceDied   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 69
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 2
dl 0
loc 69
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A via() 0 4 1
A toSms() 0 21 3
A toArray() 0 6 1
1
<?php
2
3
namespace Gamer\Notifications\Organizer;
4
5
use Illuminate\Bus\Queueable;
6
use Illuminate\Contracts\Queue\ShouldQueue;
7
use Illuminate\Queue\SerializesModels;
8
use Illuminate\Notifications\Messages\MailMessage;
9
use Illuminate\Notifications\Notification;
10
use NotificationChannels\Zenvia\ZenviaChannel;
11
use NotificationChannels\Zenvia\ZenviaMessage;
12
use Log;
13
use Gamer\Channels\SmsChannel;
14
use Gamer\Channels\Messages\SmsMessage;
15
16
class ServiceDied extends Notification implements ShouldQueue
17
{
18
    use Queueable;
19
20
    protected $_business = null;
21
22
    /**
23
     * Create a new notification instance.
24
     *
25
     * @param  $businessToken
26
     * @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...
27
     */
28
    public function __construct($business)
29
    {
30
        $this->_business = $business;
31
    }
32
33
    /**
34
     * Get the notification's delivery channels.
35
     *
36
     * @param  mixed $notifiable
37
     * @return array
38
     */
39
    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...
40
    {
41
        return [SmsChannel::class];
42
    }
43
44
    /**
45
     * Get the mail representation of the notification.
46
     *
47
     * @param  mixed $notifiable
48
     * @return \Illuminate\Notifications\Messages\MailMessage
49
     */
50
    public function toSms($notifiable)
51
    {
52
        $number = \App\Sitec\Filter::phone($notifiable->telefone_celular);
53
54
        $nomeProdutora = '';
55
        if (!empty($this->_business) && isset($this->_business->nome)) {
56
            $nomeProdutora = $this->_business->nome;
57
        }
58
59
        $message = $notifiable->token_sms ." Token SMS ". $nomeProdutora .". Insira o token para validar sua conta.";
60
        Log::debug(
61
            '[Notification] Esqueci minha Senha > Mensagem: '.$message.
62
            ' Numero: '.$number
63
        );
64
65
        return SmsMessage::create()
66
            ->from('Passepague') // optional
67
            ->to($number) // your user phone
68
            ->content($message);
69
            // ->id('your-sms-id');
70
    }
71
72
    /**
73
     * Get the array representation of the notification.
74
     *
75
     * @param  mixed $notifiable
76
     * @return array
77
     */
78
    public function toArray($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...
79
    {
80
        return [
81
            //
82
        ];
83
    }
84
}