Passed
Push — master ( 98205f...6f7a23 )
by Thierry
02:22
created

DialogLibraryTrait::getCss()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
/**
4
 * DialogLibraryTrait.php
5
 *
6
 * Common functions for javascript dialog libraries.
7
 *
8
 * @package jaxon-core
0 ignored issues
show
Coding Style introduced by
Package name "jaxon-core" is not valid; consider "Jaxoncore" instead
Loading history...
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
 */
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...
14
15
namespace Jaxon\Ui\Dialog\Library;
16
17
use Jaxon\Response\Response;
18
19
trait DialogLibraryTrait
0 ignored issues
show
Coding Style introduced by
Missing doc comment for trait DialogLibraryTrait
Loading history...
20
{
21
    /**
22
     * The dialog library helper
23
     *
24
     * @var DialogLibraryHelper
25
     */
26
    protected $xHelper;
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line(s) before first member var; 0 found
Loading history...
27
28
    /**
29
     * @var Response
30
     */
31
    protected $xResponse = null;
32
33
    /**
34
     * For MessageInterface, tells if the calls to the functions shall
35
     * add commands to the response or return the js code. By default, they add commands.
36
     *
37
     * @var bool
0 ignored issues
show
Bug introduced by
Expected "boolean" but found "bool" for @var tag in member variable comment
Loading history...
38
     */
39
    protected $bReturnCode = false;
40
41
    /**
42
     * Get the library name
43
     *
44
     * @return string
45
     */
46
    abstract public function getName(): string;
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines before function; 1 found
Loading history...
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
47
48
    /**
49
     * Get the helper
50
     *
51
     * @return DialogLibraryHelper
52
     */
53
    final protected function helper(): DialogLibraryHelper
54
    {
55
        return $this->xHelper;
56
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
57
58
    /**
59
     * Set the response to attach the messages to.
60
     *
61
     * @param Response $xResponse    Whether to return the code
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter name; 4 found
Loading history...
62
     *
63
     * @return void
64
     */
65
    final public function setResponse(Response $xResponse)
66
    {
67
        $this->xResponse = $xResponse;
68
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
69
70
    /**
71
     * Get the <Jaxon\Response\Response> object
72
     *
73
     * @return Response
74
     */
75
    final protected function response(): Response
76
    {
77
        return $this->xResponse;
78
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
79
80
    /**
81
     * @param bool $bReturnCode
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
82
     *
83
     * @return void
84
     */
85
    final public function setReturnCode(bool $bReturnCode)
86
    {
87
        $this->bReturnCode = $bReturnCode;
88
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
89
90
    /**
91
     * Check if the library should return the js code or run it in the browser.
92
     *
93
     * @return bool
94
     */
95
    final protected function returnCode(): bool
96
    {
97
        return $this->bReturnCode;
98
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
99
100
    /**
101
     * Add a client side plugin command to the response object
102
     *
103
     * @param array $aAttributes The attributes of the command
104
     * @param mixed $xData The data to be added to the command
0 ignored issues
show
Coding Style introduced by
Expected 7 spaces after parameter name; 1 found
Loading history...
105
     *
106
     * @return void
107
     */
108
    final public function addCommand(array $aAttributes, $xData)
109
    {
110
        $aAttributes['plg'] = $this->getName();
111
        $this->xResponse->addCommand($aAttributes, $xData);
112
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
113
114
    /**
115
     * Get the library base URI
116
     *
117
     * @return string
118
     */
119
    public function getUri(): string
120
    {
121
        return 'https://cdn.jaxon-php.org/libs';
122
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
123
124
    /**
125
     * Get the library subdir for the URI
126
     *
127
     * @return string
128
     */
129
    public function getSubdir(): string
130
    {
131
        return '';
132
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
133
134
    /**
135
     * Get the library version for the URI
136
     *
137
     * @return string
138
     */
139
    public function getVersion(): string
140
    {
141
        return '';
142
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
143
144
    /**
145
     * Get the CSS header code and file includes
146
     *
147
     * @return string
148
     */
149
    public function getJs(): string
150
    {
151
        return '';
152
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
153
154
    /**
155
     * Get the javascript header code and file includes
156
     *
157
     * @return string
158
     */
159
    public function getCss(): string
160
    {
161
        return '';
162
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
163
164
    /**
165
     * Get the javascript code to be printed into the page
166
     *
167
     * @return string
168
     */
169
    public function getScript(): string
170
    {
171
        return '';
172
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
173
174
    /**
175
     * Get the javascript code to be executed on page load
176
     *
177
     * @return string
178
     */
179
    public function getReadyScript(): string
180
    {
181
        return '';
182
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 0 found
Loading history...
183
}
184