Passed
Push — master ( 6251ab...a07882 )
by Thierry
01:53
created

JsTrait::removeHandler()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 3
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * JsTrait.php - Provides javascript related commands for the Response
5
 *
6
 * @author Thierry Feuzeu <[email protected]>
7
 * @license https://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License
8
 * @link https://github.com/jaxon-php/jaxon-core
9
 */
0 ignored issues
show
Coding Style introduced by
PHP version not specified
Loading history...
Coding Style introduced by
Missing @package tag in file comment
Loading history...
Coding Style introduced by
Missing @category tag in file comment
Loading history...
10
11
namespace Jaxon\Response\Traits;
12
13
use Jaxon\Response\Response;
14
use Jaxon\Exception\RequestException;
15
16
use function strpos;
17
use function strrpos;
18
use function strlen;
19
use function substr;
20
use function parse_str;
21
use function rawurlencode;
22
use function str_replace;
23
use function call_user_func;
24
use function func_get_args;
25
use function array_shift;
26
27
trait JsTrait
0 ignored issues
show
Coding Style introduced by
Missing doc comment for trait JsTrait
Loading history...
28
{
29
    /**
30
     * Add a response command to the array of commands that will be sent to the browser
31
     *
32
     * @param array $aAttributes    Associative array of attributes that will describe the command
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter name; 4 found
Loading history...
33
     * @param mixed $mData    The data to be associated with this command
0 ignored issues
show
Coding Style introduced by
Expected 7 spaces after parameter name; 4 found
Loading history...
34
     *
35
     * @return Response
36
     */
37
    abstract public function addCommand(array $aAttributes, $mData): Response;
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
Coding Style introduced by
Expected 2 blank lines before function; 0 found
Loading history...
38
39
    /**
40
     * Add a response command to the array of commands that will be sent to the browser
41
     *
42
     * @param string $sName    The command name
0 ignored issues
show
Coding Style introduced by
Expected 8 spaces after parameter name; 4 found
Loading history...
43
     * @param array $aAttributes    Associative array of attributes that will describe the command
0 ignored issues
show
Coding Style introduced by
Expected 2 spaces after parameter type; 1 found
Loading history...
Coding Style introduced by
Expected 2 spaces after parameter name; 4 found
Loading history...
44
     * @param mixed $mData    The data to be associated with this command
0 ignored issues
show
Coding Style introduced by
Expected 2 spaces after parameter type; 1 found
Loading history...
Coding Style introduced by
Expected 8 spaces after parameter name; 4 found
Loading history...
45
     * @param bool $bRemoveEmpty    If true, remove empty attributes
0 ignored issues
show
Coding Style introduced by
Expected 3 spaces after parameter type; 1 found
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter name; 4 found
Loading history...
46
     *
47
     * @return Response
48
     */
49
    abstract protected function _addCommand(string $sName, array $aAttributes, $mData, bool $bRemoveEmpty = false): Response;
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
50
51
    /**
52
     * Merge the response commands from the specified <Response> object with
53
     * the response commands in this <Response> object
54
     *
55
     * @param Response|array $mCommands    The <Response> object
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter name; 4 found
Loading history...
56
     * @param bool $bBefore    Add the new commands to the beginning of the list
0 ignored issues
show
Coding Style introduced by
Expected 3 spaces after parameter name; 4 found
Loading history...
Coding Style introduced by
Expected 11 spaces after parameter type; 1 found
Loading history...
57
     *
58
     * @return void
59
     */
60
    abstract public function appendResponse($mCommands, bool $bBefore = false);
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
61
62
    /**
63
     * Response command that prompts user with [ok] [cancel] style message box
64
     *
65
     * If the user clicks cancel, the specified number of response commands
66
     * following this one, will be skipped.
67
     *
68
     * @param integer $nCommandCount    The number of commands to skip upon cancel
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter name; 4 found
Loading history...
69
     * @param string $sMessage    The message to display to the user
0 ignored issues
show
Coding Style introduced by
Expected 6 spaces after parameter name; 4 found
Loading history...
Coding Style introduced by
Expected 2 spaces after parameter type; 1 found
Loading history...
70
     *
71
     * @return Response
72
     */
73
    public function confirmCommands(int $nCommandCount, string $sMessage): Response
74
    {
75
        $aAttributes = ['count' => $nCommandCount];
76
        return $this->_addCommand('cc', $aAttributes, $sMessage);
77
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
78
79
    /**
80
     * Response command that prompts user with [ok] [cancel] style message box
81
     *
82
     * If the user clicks cancel, the specified number of response commands
83
     * following this one, will be skipped.
84
     *
85
     * @param string $sMessage The message to display to the user
0 ignored issues
show
Coding Style introduced by
Expected 3 spaces after parameter type; 1 found
Loading history...
Coding Style introduced by
Expected 2 spaces after parameter name; 1 found
Loading history...
86
     * @param callable $xCallable The function
87
     *
88
     * @return Response
89
     * @throws RequestException
90
     */
91
    public function confirm(string $sMessage, callable $xCallable): Response
92
    {
93
        $xResponse = $this->newResponse();
0 ignored issues
show
Bug introduced by
It seems like newResponse() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

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

93
        /** @scrutinizer ignore-call */ 
94
        $xResponse = $this->newResponse();
Loading history...
94
        call_user_func($xCallable, $xResponse);
95
        $nCommandCount = $xResponse->getCommandCount();
96
        if($nCommandCount > 0)
97
        {
98
            $this->confirmCommands($nCommandCount, $sMessage);
99
            $this->appendResponse($xResponse);
100
        }
101
        return $this;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this returns the type Jaxon\Response\Traits\JsTrait which includes types incompatible with the type-hinted return Jaxon\Response\Response.
Loading history...
102
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
103
104
    /**
105
     * Add a command to display an alert message to the user
106
     *
107
     * @param string $sMessage    The message to be displayed
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter name; 4 found
Loading history...
108
     *
109
     * @return Response
110
     */
111
    public function alert(string $sMessage): Response
112
    {
113
        return $this->_addCommand('al', [], $sMessage);
114
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
115
116
    /**
117
     * Add a command to display a debug message to the user
118
     *
119
     * @param string $sMessage    The message to be displayed
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter name; 4 found
Loading history...
120
     *
121
     * @return Response
122
     */
123
    public function debug(string $sMessage): Response
124
    {
125
        return $this->_addCommand('dbg', [], $sMessage);
126
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
127
128
    /**
129
     * Add a command to ask the browser to navigate to the specified URL
130
     *
131
     * @param string $sURL    The relative or fully qualified URL
0 ignored issues
show
Coding Style introduced by
Expected 2 spaces after parameter type; 1 found
Loading history...
Coding Style introduced by
Expected 3 spaces after parameter name; 4 found
Loading history...
132
     * @param integer $nDelay    Number of seconds to delay before the redirect occurs
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter name; 4 found
Loading history...
133
     *
134
     * @return Response
135
     */
136
    public function redirect(string $sURL, int $nDelay = 0): Response
137
    {
138
        // we need to parse the query part so that the values are rawurlencode()'ed
139
        // can't just use parse_url() cos we could be dealing with a relative URL which
140
        // parse_url() can't deal with.
141
        $queryStart = strpos($sURL, '?', strrpos($sURL, '/'));
142
        if($queryStart !== false)
143
        {
144
            $queryStart++;
145
            $queryEnd = strpos($sURL, '#', $queryStart);
146
            if($queryEnd === false)
147
            {
148
                $queryEnd = strlen($sURL);
149
            }
150
            $queryPart = substr($sURL, $queryStart, $queryEnd - $queryStart);
151
            parse_str($queryPart, $queryParts);
152
            $newQueryPart = "";
153
            if($queryParts)
154
            {
155
                $first = true;
156
                foreach($queryParts as $key => $value)
157
                {
158
                    if($first)
159
                    {
160
                        $first = false;
161
                    }
162
                    else
163
                    {
164
                        $newQueryPart .= '&';
165
                    }
166
                    $newQueryPart .= rawurlencode($key) . '=' . rawurlencode($value);
167
                }
168
            }
169
            elseif($_SERVER['QUERY_STRING'])
170
            {
171
                //couldn't break up the query, but there's one there
172
                //possibly "http://url/page.html?query1234" type of query?
173
                //just encode it and hope it works
174
                $newQueryPart = rawurlencode($_SERVER['QUERY_STRING']);
175
            }
176
            $sURL = str_replace($queryPart, $newQueryPart, $sURL);
177
        }
178
179
        if($nDelay > 0)
180
        {
181
            return $this->script('window.setTimeout("window.location = \'' . $sURL . '\';",' . ($nDelay * 1000) . ');');
182
        }
183
        return $this->script('window.location = "' . $sURL . '";');
184
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
185
186
    /**
187
     * Add a command to execute a portion of javascript on the browser
188
     *
189
     * The script runs in its own context, so variables declared locally, using the 'var' keyword,
190
     * will no longer be available after the call.
191
     * To construct a variable that will be accessible globally, even after the script has executed,
192
     * leave off the 'var' keyword.
193
     *
194
     * @param string $sJS    The script to execute
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter name; 4 found
Loading history...
195
     *
196
     * @return Response
197
     */
198
    public function script(string $sJS): Response
199
    {
200
        return $this->_addCommand('js', [], $sJS);
201
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
202
203
    /**
204
     * Add a command to call the specified javascript function with the given (optional) parameters
205
     *
206
     * @param string $sFunc    The name of the function to call
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter name; 4 found
Loading history...
207
     *
208
     * @return Response
209
     */
210
    public function call(string $sFunc): Response
211
    {
212
        $aArgs = func_get_args();
213
        array_shift($aArgs);
214
        $aAttributes = ['cmd' => 'jc', 'func' => $sFunc];
215
        return $this->addCommand($aAttributes, $aArgs);
216
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
217
218
    /**
219
     * Add a command to set an event handler on the browser
220
     *
221
     * @param string $sTarget    The id of the element that contains the event
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter name; 4 found
Loading history...
222
     * @param string $sEvent    The name of the event
0 ignored issues
show
Coding Style introduced by
Expected 2 spaces after parameter name; 4 found
Loading history...
223
     * @param string $sScript    The javascript to execute when the event is fired
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter name; 4 found
Loading history...
224
     *
225
     * @return Response
226
     */
227
    public function setEvent(string $sTarget, string $sEvent, string $sScript): Response
228
    {
229
        $aAttributes = ['id' => $sTarget, 'prop' => $sEvent];
230
        return $this->_addCommand('ev', $aAttributes, $sScript);
231
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
232
233
    /**
234
     * Add a command to set a click handler on the browser
235
     *
236
     * @param string $sTarget    The id of the element that contains the event
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter name; 4 found
Loading history...
237
     * @param string $sScript    The javascript to execute when the event is fired
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter name; 4 found
Loading history...
238
     *
239
     * @return Response
240
     */
241
    public function onClick(string $sTarget, string $sScript): Response
242
    {
243
        return $this->setEvent($sTarget, 'onclick', $sScript);
244
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
245
246
    /**
247
     * Add a command to install an event handler on the specified element
248
     *
249
     * You can add more than one event handler to an element's event using this method.
250
     *
251
     * @param string $sTarget    The id of the element
0 ignored issues
show
Coding Style introduced by
Expected 2 spaces after parameter name; 4 found
Loading history...
252
     * @param string $sEvent    The name of the event
0 ignored issues
show
Coding Style introduced by
Expected 3 spaces after parameter name; 4 found
Loading history...
253
     * @param string $sHandler    The name of the javascript function to call when the event is fired
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter name; 4 found
Loading history...
254
     *
255
     * @return Response
256
     */
257
    public function addHandler(string $sTarget, string $sEvent, string $sHandler): Response
258
    {
259
        $aAttributes = ['id' => $sTarget, 'prop' => $sEvent];
260
        return $this->_addCommand('ah', $aAttributes, $sHandler);
261
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
262
263
    /**
264
     * Add a command to remove an event handler from an element
265
     *
266
     * @param string $sTarget    The id of the element
0 ignored issues
show
Coding Style introduced by
Expected 2 spaces after parameter name; 4 found
Loading history...
267
     * @param string $sEvent    The name of the event
0 ignored issues
show
Coding Style introduced by
Expected 3 spaces after parameter name; 4 found
Loading history...
268
     * @param string $sHandler    The name of the javascript function called when the event is fired
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter name; 4 found
Loading history...
269
     *
270
     * @return Response
271
     */
272
    public function removeHandler(string $sTarget, string $sEvent, string $sHandler): Response
273
    {
274
        $aAttributes = ['id' => $sTarget, 'prop' => $sEvent];
275
        return $this->_addCommand('rh', $aAttributes, $sHandler);
276
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
277
278
    /**
279
     * Add a command to construct a javascript function on the browser
280
     *
281
     * @param string $sFunction    The name of the function to construct
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter name; 4 found
Loading history...
282
     * @param string $sArgs    Comma separated list of parameter names
0 ignored issues
show
Coding Style introduced by
Expected 5 spaces after parameter name; 4 found
Loading history...
283
     * @param string $sScript    The javascript code that will become the body of the function
0 ignored issues
show
Coding Style introduced by
Expected 3 spaces after parameter name; 4 found
Loading history...
284
     *
285
     * @return Response
286
     */
287
    public function setFunction(string $sFunction, string $sArgs, string $sScript): Response
288
    {
289
        $aAttributes = ['func' => $sFunction, 'prop' => $sArgs];
290
        return $this->_addCommand('sf', $aAttributes, $sScript);
291
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
292
293
    /**
294
     * Add a command to construct a wrapper function around an existing javascript function on the browser
295
     *
296
     * @param string $sFunction    The name of the existing function to wrap
0 ignored issues
show
Coding Style introduced by
Expected 7 spaces after parameter name; 4 found
Loading history...
297
     * @param string $sArgs    The comma separated list of parameters for the function
0 ignored issues
show
Coding Style introduced by
Expected 11 spaces after parameter name; 4 found
Loading history...
298
     * @param array $aScripts    An array of javascript code snippets that will be used to build
0 ignored issues
show
Coding Style introduced by
Expected 8 spaces after parameter name; 4 found
Loading history...
Coding Style introduced by
Expected 2 spaces after parameter type; 1 found
Loading history...
299
     *                                             the body of the function
0 ignored issues
show
Coding Style introduced by
Parameter comment not aligned correctly; expected 27 spaces but found 45
Loading history...
300
     *                                             The first piece of code specified in the array will occur before
0 ignored issues
show
Coding Style introduced by
Parameter comment not aligned correctly; expected 27 spaces but found 45
Loading history...
301
     *                                             the call to the original function, the second will occur after
0 ignored issues
show
Coding Style introduced by
Parameter comment not aligned correctly; expected 27 spaces but found 45
Loading history...
302
     *                                             the original function is called.
0 ignored issues
show
Coding Style introduced by
Parameter comment not aligned correctly; expected 27 spaces but found 45
Loading history...
303
     * @param string $sReturnValueVar    The name of the variable that will retain the return value
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter name; 4 found
Loading history...
304
     *                                             from the call to the original function
0 ignored issues
show
Coding Style introduced by
Parameter comment not aligned correctly; expected 35 spaces but found 45
Loading history...
305
     *
306
     * @return Response
307
     */
308
    public function wrapFunction(string $sFunction, string $sArgs, array $aScripts, string $sReturnValueVar): Response
309
    {
310
        $aAttributes = ['cmd' => 'wpf', 'func' => $sFunction, 'prop' => $sArgs, 'type' => $sReturnValueVar];
311
        return $this->addCommand($aAttributes, $aScripts);
312
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
313
314
    /**
315
     * Add a command to load a javascript file on the browser
316
     *
317
     * @param bool $bIncludeOnce    Include once or not
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter name; 4 found
Loading history...
Coding Style introduced by
Expected 3 spaces after parameter type; 1 found
Loading history...
318
     * @param string $sFileName    The relative or fully qualified URI of the javascript file
319
     * @param string $sType    Determines the script type. Defaults to 'text/javascript'
0 ignored issues
show
Coding Style introduced by
Expected 8 spaces after parameter name; 4 found
Loading history...
320
     * @param string $sId    The wrapper id
0 ignored issues
show
Coding Style introduced by
Expected 10 spaces after parameter name; 4 found
Loading history...
321
     *
322
     * @return Response
323
     */
324
    private function _includeScript(bool $bIncludeOnce, string $sFileName, string $sType, string $sId): Response
325
    {
326
        $aAttributes = ['type' => $sType, 'elm_id' => $sId];
327
        return $this->_addCommand(($bIncludeOnce ? 'ino' : 'in'), $aAttributes, $sFileName, true);
328
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
329
330
    /**
331
     * Add a command to load a javascript file on the browser
332
     *
333
     * @param string $sFileName    The relative or fully qualified URI of the javascript file
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter name; 4 found
Loading history...
334
     * @param string $sType    Determines the script type. Defaults to 'text/javascript'
0 ignored issues
show
Coding Style introduced by
Expected 5 spaces after parameter name; 4 found
Loading history...
335
     * @param string $sId    The wrapper id
0 ignored issues
show
Coding Style introduced by
Expected 7 spaces after parameter name; 4 found
Loading history...
336
     *
337
     * @return Response
338
     */
339
    public function includeScript(string $sFileName, string $sType = '', string $sId = ''): Response
340
    {
341
        return $this->_includeScript(false, $sFileName, $sType, $sId);
342
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
343
344
    /**
345
     * Add a command to include a javascript file on the browser if it has not already been loaded
346
     *
347
     * @param string $sFileName    The relative or fully qualified URI of the javascript file
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter name; 4 found
Loading history...
348
     * @param string $sType    Determines the script type. Defaults to 'text/javascript'
0 ignored issues
show
Coding Style introduced by
Expected 5 spaces after parameter name; 4 found
Loading history...
349
     * @param string $sId    The wrapper id
0 ignored issues
show
Coding Style introduced by
Expected 7 spaces after parameter name; 4 found
Loading history...
350
     *
351
     * @return Response
352
     */
353
    public function includeScriptOnce(string $sFileName, string $sType = '', string $sId = ''): Response
354
    {
355
        return $this->_includeScript(true, $sFileName, $sType, $sId);
356
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
357
358
    /**
359
     * Add a command to remove a SCRIPT reference to a javascript file on the browser
360
     *
361
     * Optionally, you can call a javascript function just prior to the file being unloaded (for cleanup).
362
     *
363
     * @param string $sFileName    The relative or fully qualified URI of the javascript file
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter name; 4 found
Loading history...
364
     * @param string $sUnload    Name of a javascript function to call prior to unlaoding the file
0 ignored issues
show
Coding Style introduced by
Expected 3 spaces after parameter name; 4 found
Loading history...
365
     *
366
     * @return Response
367
     */
368
    public function removeScript(string $sFileName, string $sUnload = ''): Response
369
    {
370
        $aAttributes = ['unld' => $sUnload];
371
        return $this->_addCommand('rjs', $aAttributes, $sFileName, true);
372
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
373
374
    /**
375
     * Add a command to include a LINK reference to the specified CSS file on the browser.
376
     *
377
     * This will cause the browser to load and apply the style sheet.
378
     *
379
     * @param string $sFileName    The relative or fully qualified URI of the css file
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter name; 4 found
Loading history...
380
     * @param string $sMedia    The media type of the CSS file. Defaults to 'screen'
381
     *
382
     * @return Response
383
     */
384
    public function includeCSS(string $sFileName, string $sMedia = ''): Response
0 ignored issues
show
Coding Style introduced by
This method is not in camel caps format.

This check looks for method names that are not written in camelCase.

In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. Thus the name database connection seeker becomes databaseConnectionSeeker.

Loading history...
385
    {
386
        $aAttributes = ['media' => $sMedia];
387
        return $this->_addCommand('css', $aAttributes, $sFileName, true);
388
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
389
390
    /**
391
     * Add a command to remove a LINK reference to a CSS file on the browser
392
     *
393
     * This causes the browser to unload the style sheet, effectively removing the style changes it caused.
394
     *
395
     * @param string $sFileName The relative or fully qualified URI of the css file
396
     * @param string $sMedia
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
397
     *
398
     * @return Response
399
     */
400
    public function removeCSS(string $sFileName, string $sMedia = ''): Response
0 ignored issues
show
Coding Style introduced by
This method is not in camel caps format.

This check looks for method names that are not written in camelCase.

In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. Thus the name database connection seeker becomes databaseConnectionSeeker.

Loading history...
401
    {
402
        $aAttributes = ['media' => $sMedia];
403
        return $this->_addCommand('rcss', $aAttributes, $sFileName, true);
404
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
405
406
    /**
407
     * Add a command to make Jaxon pause while the CSS files are loaded
408
     *
409
     * The browser is not typically a multi-threading application, with regards to javascript code.
410
     * Therefore, the CSS files included or removed with <Response->includeCSS> and
411
     * <Response->removeCSS> respectively, will not be loaded or removed until the browser regains
412
     * control from the script.
413
     * This command returns control back to the browser and pauses the execution of the response
414
     * until the CSS files, included previously, are loaded.
415
     *
416
     * @param integer $nTimeout    The number of 1/10ths of a second to pause before timing out
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter name; 4 found
Loading history...
417
     *                                             and continuing with the execution of the response commands
0 ignored issues
show
Coding Style introduced by
Parameter comment not aligned correctly; expected 29 spaces but found 45
Loading history...
418
     *
419
     * @return Response
420
     */
421
    public function waitForCSS(int $nTimeout = 600): Response
0 ignored issues
show
Coding Style introduced by
This method is not in camel caps format.

This check looks for method names that are not written in camelCase.

In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. Thus the name database connection seeker becomes databaseConnectionSeeker.

Loading history...
422
    {
423
        $aAttributes = ['cmd' => 'wcss', 'prop' => $nTimeout];
424
        return $this->addCommand($aAttributes, '');
425
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
426
427
    /**
428
     * Add a command to make Jaxon to delay execution of the response commands until a specified condition is met
429
     *
430
     * Note, this returns control to the browser, so that other script operations can execute.
431
     * Jaxon will continue to monitor the specified condition and, when it evaluates to true,
432
     * will continue processing response commands.
433
     *
434
     * @param string $script    A piece of javascript code that evaulates to true or false
0 ignored issues
show
Coding Style introduced by
Expected 2 spaces after parameter type; 1 found
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter name; 4 found
Loading history...
435
     * @param integer $tenths    The number of 1/10ths of a second to wait before timing out
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter name; 4 found
Loading history...
436
     *                                             and continuing with the execution of the response commands.
0 ignored issues
show
Coding Style introduced by
Parameter comment not aligned correctly; expected 27 spaces but found 45
Loading history...
437
     *
438
     * @return Response
439
     */
440
    public function waitFor(string $script, int $tenths): Response
441
    {
442
        $aAttributes = ['cmd' => 'wf', 'prop' => $tenths];
443
        return $this->addCommand($aAttributes, $script);
444
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
445
446
    /**
447
     * Add a command to make Jaxon to pause execution of the response commands,
448
     * returning control to the browser so it can perform other commands asynchronously.
449
     *
450
     * After the specified delay, Jaxon will continue execution of the response commands.
451
     *
452
     * @param integer $tenths    The number of 1/10ths of a second to sleep
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter name; 4 found
Loading history...
453
     *
454
     * @return Response
455
     */
456
    public function sleep(int $tenths): Response
457
    {
458
        $aAttributes = ['cmd' =>'s', 'prop' => $tenths];
0 ignored issues
show
Coding Style introduced by
Expected 1 space after "=>"; 0 found
Loading history...
459
        return $this->addCommand($aAttributes, '');
460
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 0 found
Loading history...
461
}
462