Pnotify   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A options() 0 4 1
A notify() 0 10 2
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