Passed
Push — master ( 2cb546...9b3a22 )
by Thierry
08:13
created

NotifyLibrary::warning()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 2
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * DialogLibraryInterface.php - Adapter for the Notify library.
5
 *
6
 * @package jaxon-dialogs
7
 * @author Thierry Feuzeu <[email protected]>
8
 * @copyright 2016 Thierry Feuzeu <[email protected]>
9
 * @license https://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License
10
 * @link https://github.com/jaxon-php/jaxon-dialogs
11
 */
12
13
namespace Jaxon\Dialogs\Notify;
14
15
use Jaxon\App\Dialog\Library\DialogLibraryTrait;
16
use Jaxon\App\Dialog\LibraryInterface;
17
use Jaxon\App\Dialog\MessageInterface;
18
19
class NotifyLibrary implements LibraryInterface, MessageInterface
20
{
21
    use DialogLibraryTrait;
22
23
    /**
24
     * @const The library name
25
     */
26
    const NAME = 'notify';
27
28
    /**
29
     * @inheritDoc
30
     */
31
    public function getName(): string
32
    {
33
        return self::NAME;
34
    }
35
36
    /**
37
     * @inheritDoc
38
     */
39
    public function getSubdir(): string
40
    {
41
        return 'notify';
42
    }
43
44
    /**
45
     * @inheritDoc
46
     */
47
    public function getVersion(): string
48
    {
49
        return '0.4.2';
50
    }
51
52
    /**
53
     * @inheritDoc
54
     */
55
    public function getJs(): string
56
    {
57
        return $this->helper()->getJsCode('notify.js');
58
    }
59
60
    /**
61
     * @inheritDoc
62
     */
63
    public function getScript(): string
64
    {
65
        return $this->helper()->render('notify/alert.js');
66
    }
67
68
    /**
69
     * @inheritDoc
70
     */
71
    public function getReadyScript(): string
72
    {
73
        return $this->helper()->render('notify/ready.js.php');
74
    }
75
76
    /**
77
     * Print an alert message.
78
     *
79
     * @param string $sMessage The text of the message
80
     * @param string $sTitle The title of the message
81
     * @param string $sClass The type of the message
82
     *
83
     * @return string
84
     */
85
    protected function alert(string $sMessage, string $sTitle, string $sClass): string
0 ignored issues
show
Unused Code introduced by
The parameter $sTitle is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

85
    protected function alert(string $sMessage, /** @scrutinizer ignore-unused */ string $sTitle, string $sClass): string

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
86
    {
87
        if($this->returnCode())
88
        {
89
            return "$.notify(" . $sMessage . ", {className:'" . $sClass . "', position:'top center'})";
90
        }
91
        $aOptions = array('message' => $sMessage, 'className' => $sClass);
92
        // Show the alert
93
        $this->addCommand(array('cmd' => 'notify.alert'), $aOptions);
94
        return '';
95
    }
96
97
    /**
98
     * @inheritDoc
99
     */
100
    public function success(string $sMessage, string $sTitle = ''): string
101
    {
102
        return $this->alert($sMessage, $sTitle, 'success');
103
    }
104
105
    /**
106
     * @inheritDoc
107
     */
108
    public function info(string $sMessage, string $sTitle = ''): string
109
    {
110
        return $this->alert($sMessage, $sTitle, 'info');
111
    }
112
113
    /**
114
     * @inheritDoc
115
     */
116
    public function warning(string $sMessage, string $sTitle = ''): string
117
    {
118
        return $this->alert($sMessage, $sTitle, 'warn');
119
    }
120
121
    /**
122
     * @inheritDoc
123
     */
124
    public function error(string $sMessage, string $sTitle = ''): string
125
    {
126
        return $this->alert($sMessage, $sTitle, 'error');
127
    }
128
}
129