Notifiable   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
c 1
b 0
f 0
dl 0
loc 53
rs 10
wmc 6

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getNotificationPhoneNumber() 0 3 1
A routeNotificationFor() 0 16 3
A getNotificationEmail() 0 3 1
A notify() 0 3 1
1
<?php
2
3
namespace ByTIC\Notifications;
4
5
use ByTIC\Notifications\Dispatcher\DispatcherInterface;
6
7
/**
8
 * Class Notifiable
9
 * @package ByTIC\Notifications
10
 *
11
 * @property string $email
12
 * @property string $phone_number
13
 */
14
trait Notifiable
15
{
16
    /**
17
     * Send the given notification.
18
     *
19
     * @param  Notification $notification
20
     *
21
     * @return void
22
     */
23
    public function notify($notification)
24
    {
25
        app(DispatcherInterface::class)->send($this, $notification);
26
    }
27
28
    /**
29
     * Get the notification routing information for the given driver.
30
     *
31
     * @param  string $driver
32
     *
33
     * @return mixed
34
     */
35
    public function routeNotificationFor($driver)
36
    {
37
//        if (method_exists($this, $method = 'routeNotificationFor'.Str::studly($driver))) {
38
//            return $this->{$method}();
39
//        }
40
41
        switch ($driver) {
42
//            case 'database':
43
//                return $this->notifications();
44
            case 'mail':
45
                return $this->getNotificationEmail();
46
            case 'nexmo':
47
                return $this->getNotificationPhoneNumber();
48
        }
49
50
        return null;
51
    }
52
53
    /**
54
     * @return string
55
     */
56
    public function getNotificationEmail()
57
    {
58
        return $this->email;
59
    }
60
61
    /**
62
     * @return string
63
     */
64
    public function getNotificationPhoneNumber()
65
    {
66
        return $this->phone_number;
67
    }
68
}
69