Pnotify::notify()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 4
dl 0
loc 10
rs 9.9332
c 0
b 0
f 0
1
<?php
2
3
namespace Yoeunes\Notify\Notifiers;
4
5
class Pnotify extends AbstractNotifier implements NotifierInterface
6
{
7
    /**
8
     * Get global toastr options.
9
     *
10
     * @return string
11
     */
12
    public function options(): string
13
    {
14
        return 'PNotify.defaults = '.json_encode($this->config['options']).';';
15
    }
16
17
    /**
18
     * Create a single notification.
19
     *
20
     * @param string $type
21
     * @param string $message
22
     * @param string|null $title
23
     * @param string|null $options
24
     *
25
     * @return string
26
     */
27
    public function notify(string $type, string $message = '', string $title = '', string $options = ''): string
28
    {
29
        $options = substr($options, 1, -1);
30
31
        if (empty($options)) {
32
            return "new PNotify({title:'$title', text:'$message', type:'$type'});";
33
        }
34
35
        return "new PNotify({title:'$title', text:'$message', type:'$type', $options});";
36
    }
37
}
38