Passed
Push — master ( b34d93...aea763 )
by Thierry
03:02 queued 24s
created

DialogLibraryManager::setMessageLibrary()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
/**
4
 * DialogLibraryManager.php - Shows alert and confirm dialogs
5
 *
6
 * @author Thierry Feuzeu <[email protected]>
7
 * @copyright 2019 Thierry Feuzeu <[email protected]>
8
 * @license https://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License
9
 * @link https://github.com/jaxon-php/jaxon-core
10
 */
0 ignored issues
show
Coding Style introduced by
PHP version not specified
Loading history...
Coding Style introduced by
Missing @category tag in file comment
Loading history...
Coding Style introduced by
Missing @package tag in file comment
Loading history...
11
12
namespace Jaxon\Ui\Dialog\Library;
13
14
use Jaxon\Di\Container;
15
use Jaxon\Ui\Dialog\MessageInterface;
16
use Jaxon\Ui\Dialog\ModalInterface;
17
use Jaxon\Ui\Dialog\QuestionInterface;
18
19
class DialogLibraryManager
0 ignored issues
show
Coding Style introduced by
Missing doc comment for class DialogLibraryManager
Loading history...
20
{
21
    /**
22
     * @var Container
23
     */
24
    private $di;
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line(s) before first member var; 0 found
Loading history...
25
26
    /**
27
     * The QuestionInterface class name
28
     *
29
     * @var string
30
     */
31
    private $sQuestionLibrary = '';
32
33
    /**
34
     * The MessageInterface class name
35
     *
36
     * @var string
37
     */
38
    private $sMessageLibrary = '';
39
40
    /**
41
     * The ModalInterface class name
42
     *
43
     * @var string
44
     */
45
    private $sModalLibrary = '';
46
47
    /**
48
     * The name of the library to use for the next call.
49
     * This is used to override the default library.
50
     *
51
     * @var string
52
     */
53
    protected $sNextLibrary = '';
54
55
    /**
56
     * Default javascript alert library
57
     *
58
     * @var AlertLibrary
59
     */
60
    private $xAlertLibrary;
61
62
    /**
63
     * The constructor
64
     *
65
     * @param Container $di
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
66
     */
67
    public function __construct(Container $di)
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines before function; 1 found
Loading history...
68
    {
69
        $this->di = $di;
70
        // Library for javascript confirm and alert functions.
71
        $this->xAlertLibrary = new AlertLibrary();
72
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
73
74
    /**
75
     * Set the QuestionInterface class name
76
     *
77
     * @param string $sQuestionLibrary    The QuestionInterface class name
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter name; 4 found
Loading history...
78
     *
79
     * @return void
80
     */
81
    public function setQuestionLibrary(string $sQuestionLibrary)
82
    {
83
        $this->sQuestionLibrary = $sQuestionLibrary;
84
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
85
86
    /**
87
     * Get the QuestionInterface instance
88
     *
89
     * @return QuestionInterface
90
     */
91
    public function getQuestionLibrary()
92
    {
93
        $sQuestionLibrary = $this->sNextLibrary ?: $this->sQuestionLibrary;
94
        return ($sQuestionLibrary) ? $this->di->g($sQuestionLibrary) : $this->xAlertLibrary;
95
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
96
97
    /**
98
     * Set MessageInterface class name
99
     *
100
     * @param string $sMessageLibrary    The MessageInterface class name
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter name; 4 found
Loading history...
101
     *
102
     * @return void
103
     */
104
    public function setMessageLibrary(string $sMessageLibrary)
105
    {
106
        $this->sMessageLibrary = $sMessageLibrary;
107
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
108
109
    /**
110
     * Get the MessageInterface instance
111
     *
112
     * @return MessageInterface
113
     */
114
    public function getMessageLibrary(): MessageInterface
115
    {
116
        $sMessageLibrary = $this->sNextLibrary ?: $this->sMessageLibrary;
117
        return ($sMessageLibrary) ? $this->di->g($sMessageLibrary) : $this->xAlertLibrary;
118
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
119
120
    /**
121
     * Set the ModalInterface class name
122
     *
123
     * @param string $sModalLibrary    The ModalInterface class name
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter name; 4 found
Loading history...
124
     *
125
     * @return void
126
     */
127
    public function setModalLibrary(string $sModalLibrary)
128
    {
129
        $this->sModalLibrary = $sModalLibrary;
130
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
131
132
    /**
133
     * Get the ModalInterface instance
134
     *
135
     * @return ModalInterface
136
     */
137
    public function getModalLibrary(): ?ModalInterface
138
    {
139
        $sModalLibrary = $this->sNextLibrary ?: $this->sModalLibrary;
140
        return ($sModalLibrary) ? $this->di->g($sModalLibrary) : null;
141
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
142
143
    /**
144
     * Set the name of the library to use for the next call
145
     *
146
     * @param string $sNextLibrary
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
147
     *
148
     * @return void
149
     */
150
    public function setNextLibrary(string $sNextLibrary): void
151
    {
152
        $this->sNextLibrary = $sNextLibrary;
153
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 0 found
Loading history...
154
}
155