Behavior   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Test Coverage

Coverage 87.5%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 4
dl 0
loc 23
ccs 7
cts 8
cp 0.875
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A desktopNotify() 0 12 2
1
<?php
2
/**
3
 * @link https://github.com/vuongxuongminh/yii2-desktop-notifier
4
 * @copyright Copyright (c) 2019 Vuong Xuong Minh
5
 * @license [New BSD License](http://www.opensource.org/licenses/bsd-license.php)
6
 */
7
8
namespace vxm\desktopNotifier;
9
10
use yii\base\Behavior as BaseBehavior;
11
12
use Joli\JoliNotif\Notification;
13
use Joli\JoliNotif\NotifierFactory;
14
15
/**
16
 * Class Behavior
17
 *
18
 * @author Vuong Minh <[email protected]>
19
 * @since 1.0.0
20
 */
21
class Behavior extends BaseBehavior
22
{
23
    /**
24
     * Send desktop notify
25
     *
26
     * @param string $title of notice
27
     * @param string $body content of notice message
28
     * @param null $icon of notice
29
     */
30 1
    public function desktopNotify(string $title, string $body, $icon = null)
31
    {
32 1
        $notification = new Notification();
33 1
        $notification->setTitle($title);
34 1
        $notification->setBody($body);
35
36 1
        if ($icon !== null) {
37
            $notification->setIcon($icon);
38
        }
39
40 1
        NotifierFactory::create()->send($notification);
41 1
    }
42
43
}
44