Passed
Push — master ( 0c5836...7e4fb9 )
by Thierry
02:39
created

OverhangLibrary::getCss()   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 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * DialogLibraryInterface.php - Adapter for the Overhang 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\Library\Overhang;
14
15
use Jaxon\Ui\Dialog\Library\AbstractDialogLibrary;
0 ignored issues
show
Bug introduced by
The type Jaxon\Ui\Dialog\Library\AbstractDialogLibrary was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
16
use Jaxon\Ui\Dialog\MessageInterface;
0 ignored issues
show
Bug introduced by
The type Jaxon\Ui\Dialog\MessageInterface was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
17
use Jaxon\Ui\Dialog\QuestionInterface;
0 ignored issues
show
Bug introduced by
The type Jaxon\Ui\Dialog\QuestionInterface was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
18
19
class OverhangLibrary extends AbstractDialogLibrary implements MessageInterface, QuestionInterface
20
{
21
    /**
22
     * @const The library name
23
     */
24
    const NAME = 'overhang';
25
26
    /**
27
     * @inheritDoc
28
     */
29
    public function getName(): string
30
    {
31
        return self::NAME;
32
    }
33
34
    /**
35
     * @inheritDoc
36
     */
37
    public function getSubdir(): string
38
    {
39
        return 'overhang';
40
    }
41
42
    /**
43
     * @inheritDoc
44
     */
45
    public function getVersion(): string
46
    {
47
        return 'latest';
48
    }
49
50
    /**
51
     * @inheritDoc
52
     */
53
    public function getJs(): string
54
    {
55
        return $this->xHelper->getJsCode('overhang.min.js');
56
    }
57
58
    /**
59
     * @inheritDoc
60
     */
61
    public function getCss(): string
62
    {
63
        return $this->xHelper->getCssCode('overhang.min.css');
64
    }
65
66
    /**
67
     * @inheritDoc
68
     */
69
    public function getScript(): string
70
    {
71
        return $this->xHelper->render('overhang/alert.js');
72
    }
73
74
    /**
75
     * @inheritDoc
76
     */
77
    public function getReadyScript(): string
78
    {
79
        return $this->xHelper->render('overhang/ready.js.php');
80
    }
81
82
    /**
83
     * Print an alert message.
84
     *
85
     * @param string $sMessage The text of the message
86
     * @param string $sTitle The title of the message
87
     * @param string $sType The type of the message
88
     *
89
     * @return string
90
     */
91
    protected function alert(string $sMessage, string $sTitle, string $sType): string
92
    {
93
        if($this->returnCode())
94
        {
95
            return "$('body').overhang({message:" . $sMessage . ", type:'" . $sType . "'})";
96
        }
97
        $aOptions = ['message' => $sMessage, 'type' => $sType];
98
        // Show the alert
99
        $this->addCommand(['cmd' => 'overhang.alert'], $aOptions);
100
        return '';
101
    }
102
103
    /**
104
     * @inheritDoc
105
     */
106
    public function success(string $sMessage, string $sTitle = ''): string
107
    {
108
        return $this->alert($sMessage, $sTitle, 'success');
109
    }
110
111
    /**
112
     * @inheritDoc
113
     */
114
    public function info(string $sMessage, string $sTitle = ''): string
115
    {
116
        return $this->alert($sMessage, $sTitle, 'info');
117
    }
118
119
    /**
120
     * @inheritDoc
121
     */
122
    public function warning(string $sMessage, string $sTitle = ''): string
123
    {
124
        return $this->alert($sMessage, $sTitle, 'warn');
125
    }
126
127
    /**
128
     * @inheritDoc
129
     */
130
    public function error(string $sMessage, string $sTitle = ''): string
131
    {
132
        return $this->alert($sMessage, $sTitle, 'error');
133
    }
134
135
    /**
136
     * @inheritDoc
137
     */
138
    public function confirm(string $sQuestion, string $sYesScript, string $sNoScript): string
139
    {
140
        if(!$sNoScript)
141
        {
142
            return "jaxon.dialogs.overhang.confirm(" . $sQuestion . ",function(){" . $sYesScript . ";})";
143
        }
144
        else
145
        {
146
            return "jaxon.dialogs.overhang.confirm(" . $sQuestion . ",function(){" . $sYesScript . ";},function(){" . $sNoScript . ";})";
147
        }
148
    }
149
}
150