helpers.php ➔ notify()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 4
dl 0
loc 8
rs 10
c 0
b 0
f 0
1
<?php
2
3
use Yoeunes\Notify\Notify;
4
5
if (! function_exists('notify')) {
6
    /**
7
     * @param string $message
8
     * @param string $type
9
     * @param string $title
10
     * @param array  $options
11
     *
12
     * @return Notify
13
     */
14
    function notify(string $message = null, string $type = 'success', string $title = '', array $options = []): Notify
15
    {
16
        if (is_null($message)) {
17
            return app('notify');
18
        }
19
20
        return app('notify')->addNotification($type, $message, $title, $options);
21
    }
22
}
23
24
if (! function_exists('notify_js')) {
25
    /**
26
     * @return string
27
     */
28
    function notify_js(): string
29
    {
30
        $driver  = config('notify.default');
31
        $scripts = config('notify.'.$driver.'.notify_js');
32
33
        return '<script type="text/javascript" src="'.implode('"></script><script type="text/javascript" src="', $scripts).'"></script>';
34
    }
35
}
36
37
if (! function_exists('notify_css')) {
38
    /**
39
     * @return string
40
     */
41
    function notify_css(): string
42
    {
43
        $driver  = config('notify.default');
44
        $styles = config('notify.'.$driver.'.notify_css');
45
46
        return '<link rel="stylesheet" type="text/css" href="'.implode('"><link rel="stylesheet" type="text/css" href="', $styles).'">';
47
    }
48
}
49