Notificable   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 1
dl 0
loc 22
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A sendAppNotification() 0 11 1
1
<?php
2
3
namespace Hechoenlaravel\JarvisFoundation\Traits;
4
5
use Hechoenlaravel\JarvisFoundation\Notifications\SendAppNotification\Middleware\SetTheUserId;
6
use Hechoenlaravel\JarvisFoundation\Notifications\SendAppNotification\SendAppNotificationCommand;
7
use Hechoenlaravel\JarvisFoundation\Notifications\SendAppNotification\Handler\SendAppNotificationCommandHandler;
8
9
/**
10
 * Trait Notificable
11
 * Use this trait to send notifications to a User.
12
 * @author Jose Fonseca <[email protected]>
13
 * @package Hechoenlaravel\JarvisFoundation\Traits
14
 */
15
trait Notificable
16
{
17
    use DispatchesCommands;
18
19
    /**
20
     * @param object $user
21
     * @param $message
22
     * @param string $type
23
     * @param $link must be resolvable by url() helper
24
     */
25
    public function sendAppNotification($user, $message, $type = "info", $link = null)
26
    {
27
        $this->execute(SendAppNotificationCommand::class, SendAppNotificationCommandHandler::class, [
28
            'user' => $user,
29
            'type' => $type,
30
            'message' => $message,
31
            'link' => $link
32
        ], [
33
            SetTheUserId::class
34
        ]);
35
    }
36
}
37