NotyLibrary::getVersion()   A
last analyzed

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 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * NotyLibrary.php
5
 *
6
 * Adapter for the Noty library.
7
 *
8
 * @package jaxon-dialogs
9
 * @author Thierry Feuzeu <[email protected]>
10
 * @copyright 2016 Thierry Feuzeu <[email protected]>
11
 * @license https://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License
12
 * @link https://github.com/jaxon-php/jaxon-dialogs
13
 */
14
15
namespace Jaxon\Dialogs\Noty;
16
17
use Jaxon\App\Dialog\Library\DialogLibraryTrait;
18
use Jaxon\App\Dialog\MessageInterface;
19
use Jaxon\App\Dialog\QuestionInterface;
20
21
class NotyLibrary implements MessageInterface, QuestionInterface
22
{
23
    use DialogLibraryTrait;
24
25
    /**
26
     * @const The library name
27
     */
28
    const NAME = 'noty';
29
30
    /**
31
     * @inheritDoc
32
     */
33
    public function getName(): string
34
    {
35
        return self::NAME;
36
    }
37
38
    /**
39
     * @inheritDoc
40
     */
41
    public function getSubdir(): string
42
    {
43
        return 'noty';
44
    }
45
46
    /**
47
     * @inheritDoc
48
     */
49
    public function getVersion(): string
50
    {
51
        return '2.3.11';
52
    }
53
54
    /**
55
     * @inheritDoc
56
     */
57
    public function getJs(): string
58
    {
59
        return $this->helper()->getJsCode('jquery.noty.packaged.min.js');
60
    }
61
62
    /**
63
     * @inheritDoc
64
     */
65
    public function getScript(): string
66
    {
67
         return $this->helper()->render('noty/alert.js');
68
    }
69
70
    /**
71
     * @inheritDoc
72
     */
73
    public function getReadyScript(): string
74
    {
75
         return $this->helper()->render('noty/ready.js.php');
76
    }
77
78
    /**
79
     * Print an alert message.
80
     *
81
     * @param string $sMessage The text of the message
82
     * @param string $sTitle The title of the message
83
     * @param string $sType The type of the message
84
     *
85
     * @return string
86
     */
87
    protected function alert(string $sMessage, string $sTitle, string $sType): 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

87
    protected function alert(string $sMessage, /** @scrutinizer ignore-unused */ string $sTitle, string $sType): 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...
88
    {
89
        if($this->returnCode())
90
        {
91
            return "noty({text:" . $sMessage . ", type:'" . $sType . "', layout: 'topCenter'})";
92
        }
93
        $aOptions = array('text' => $sMessage, 'type' => $sType);
94
        // Show the alert
95
        $this->addCommand(array('cmd' => 'noty.alert'), $aOptions);
96
        return '';
97
    }
98
99
    /**
100
     * @inheritDoc
101
     */
102
    public function success(string $sMessage, string $sTitle = ''): string
103
    {
104
        return $this->alert($sMessage, $sTitle, 'success');
105
    }
106
107
    /**
108
     * @inheritDoc
109
     */
110
    public function info(string $sMessage, string $sTitle = ''): string
111
    {
112
        return $this->alert($sMessage, $sTitle, 'information');
113
    }
114
115
    /**
116
     * @inheritDoc
117
     */
118
    public function warning(string $sMessage, string $sTitle = ''): string
119
    {
120
        return $this->alert($sMessage, $sTitle, 'warning');
121
    }
122
123
    /**
124
     * @inheritDoc
125
     */
126
    public function error(string $sMessage, string $sTitle = ''): string
127
    {
128
        return $this->alert($sMessage, $sTitle, 'error');
129
    }
130
131
    /**
132
     * @inheritDoc
133
     */
134
    public function confirm(string $sQuestion, string $sYesScript, string $sNoScript): string
135
    {
136
        // $sTitle = $this->helper()->getQuestionTitle();
137
        if(!$sNoScript)
138
        {
139
            return "jaxon.dialogs.noty.confirm(" . $sQuestion . ",'',function(){" . $sYesScript . ";})";
140
        }
141
        return "jaxon.dialogs.noty.confirm(" . $sQuestion . ",'',function(){" . $sYesScript .
142
            ";},function(){" . $sNoScript . ";})";
143
    }
144
}
145