Completed
Push — master ( 2b3dd9...7d2542 )
by ARCANEDEV
08:42
created

Notifyable   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 79
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 6
c 2
b 0
f 0
lcom 1
cbo 1
dl 0
loc 79
ccs 0
cts 24
cp 0
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A notify() 0 4 1
A notifySuccess() 0 4 1
A notifyDanger() 0 4 1
A notifyWarning() 0 4 1
A notifyInfo() 0 4 1
A notifyFlash() 0 4 1
1
<?php namespace Arcanesoft\Core\Traits;
2
3
/**
4
 * Class     Notifyable
5
 *
6
 * @package  Arcanesoft\Foundation\Traits
7
 * @author   ARCANEDEV <[email protected]>
8
 */
9
trait Notifyable
10
{
11
    /* ------------------------------------------------------------------------------------------------
12
     |  Main Functions
13
     | ------------------------------------------------------------------------------------------------
14
     */
15
    /**
16
     * The notify instance.
17
     *
18
     * @param  string|null  $message
19
     *
20
     * @return \Arcanedev\Notify\Contracts\Notify
21
     */
22
    protected function notify($message = null)
23
    {
24
        return notify($message);
25
    }
26
27
    /**
28
     * Notify a success alert.
29
     *
30
     * @param  string       $message
31
     * @param  string|null  $title
32
     * @param  array        $options
33
     */
34
    protected function notifySuccess($message, $title = null, array $options = [])
35
    {
36
        $this->notifyFlash($message, 'success', $title, $options);
37
    }
38
39
    /**
40
     * Notify a danger alert.
41
     *
42
     * @param  string       $message
43
     * @param  string|null  $title
44
     * @param  array        $options
45
     */
46
    protected function notifyDanger($message, $title = null, array $options = [])
47
    {
48
        $this->notifyFlash($message, 'danger', $title, $options);
49
    }
50
51
    /**
52
     * Notify a warning alert.
53
     *
54
     * @param  string       $message
55
     * @param  string|null  $title
56
     * @param  array        $options
57
     */
58
    protected function notifyWarning($message, $title = null, array $options = [])
59
    {
60
        $this->notifyFlash($message, 'warning', $title, $options);
61
    }
62
63
    /**
64
     * Notify an info alert.
65
     *
66
     * @param  string       $message
67
     * @param  string|null  $title
68
     * @param  array        $options
69
     */
70
    protected function notifyInfo($message, $title = null, array $options = [])
71
    {
72
        $this->notifyFlash($message, 'info', $title, $options);
73
    }
74
75
    /**
76
     * Notify a flash alert.
77
     *
78
     * @param  string       $message
79
     * @param  string       $type
80
     * @param  string|null  $title
81
     * @param  array        $options
82
     */
83
    protected function notifyFlash($message, $type, $title = null, array $options = [])
84
    {
85
        $this->notify()->flash($message, $type, array_merge($options, compact('title')));
86
    }
87
}
88