Test Setup Failed
Branch feature/code_improvement (b0d56f)
by Thierry
02:54
created

JsCommands::includeScript()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
nc 1
dl 0
loc 4
c 0
b 0
f 0
cc 1
nop 3
rs 10
1
<?php
2
3
/**
4
 * Js.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 @category tag in file comment
Loading history...
Coding Style introduced by
Missing @package tag in file comment
Loading history...
10
11
namespace Jaxon\Response\Features;
12
13
trait JsCommands
0 ignored issues
show
Coding Style introduced by
Missing doc comment for trait JsCommands
Loading history...
14
{
15
    /**
16
     * Add a response command to the array of commands that will be sent to the browser
17
     *
18
     * @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 type; 9 found
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter name; 8 found
Loading history...
19
     * @param mixed            $mData                The data to be associated with this command
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter type; 12 found
Loading history...
Coding Style introduced by
Expected 7 spaces after parameter name; 16 found
Loading history...
20
     *
21
     * @return Response
22
     */
23
    abstract public function addCommand(array $aAttributes, $mData);
24
25
    /**
26
     * Add a response command to the array of commands that will be sent to the browser
27
     *
28
     * @param string        $sName              The command name
0 ignored issues
show
Coding Style introduced by
Expected 2 spaces after parameter type; 8 found
Loading history...
Coding Style introduced by
Expected 8 spaces after parameter name; 14 found
Loading history...
29
     * @param array         $aAttributes        Associative array of attributes that will describe the command
0 ignored issues
show
Coding Style introduced by
Expected 3 spaces after parameter type; 9 found
Loading history...
Coding Style introduced by
Expected 2 spaces after parameter name; 8 found
Loading history...
30
     * @param mixed         $mData              The data to be associated with this command
0 ignored issues
show
Coding Style introduced by
Expected 3 spaces after parameter type; 9 found
Loading history...
Coding Style introduced by
Expected 8 spaces after parameter name; 14 found
Loading history...
31
     * @param boolean       $bRemoveEmpty       If true, remove empty attributes
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter type; 7 found
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter name; 7 found
Loading history...
32
     *
33
     * @return Response
34
     */
35
    abstract protected function _addCommand($sName, array $aAttributes, $mData, $bRemoveEmpty = false);
36
37
    /**
38
     * Response command that prompts user with [ok] [cancel] style message box
39
     *
40
     * If the user clicks cancel, the specified number of response commands
41
     * following this one, will be skipped.
42
     *
43
     * @param integer        $iCmdNumber            The number of commands to skip upon cancel
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter type; 8 found
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter name; 12 found
Loading history...
44
     * @param string        $sMessage            The message to display to the user
0 ignored issues
show
Coding Style introduced by
Expected 2 spaces after parameter type; 8 found
Loading history...
Coding Style introduced by
Expected 3 spaces after parameter name; 12 found
Loading history...
45
     *
46
     * @return Response
47
     */
48
    public function confirmCommands($iCmdNumber, $sMessage)
49
    {
50
        $aAttributes = ['id' => $iCmdNumber];
51
        return $this->_addCommand('cc', $aAttributes, $sMessage);
52
    }
53
54
    /**
55
     * Add a command to display an alert message to the user
56
     *
57
     * @param string        $sMessage            The message to be displayed
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter type; 8 found
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter name; 12 found
Loading history...
58
     *
59
     * @return Response
60
     */
61
    public function alert($sMessage)
62
    {
63
        return $this->_addCommand('al', [], $sMessage);
64
    }
65
66
    /**
67
     * Add a command to display a debug message to the user
68
     *
69
     * @param string        $sMessage            The message to be displayed
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter type; 8 found
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter name; 12 found
Loading history...
70
     *
71
     * @return Response
72
     */
73
    public function debug($sMessage)
74
    {
75
        return $this->_addCommand('dbg', [], $sMessage);
76
    }
77
78
    /**
79
     * Add a command to ask the browser to navigate to the specified URL
80
     *
81
     * @param string        $sURL                The relative or fully qualified URL
0 ignored issues
show
Coding Style introduced by
Expected 2 spaces after parameter type; 8 found
Loading history...
Coding Style introduced by
Expected 3 spaces after parameter name; 16 found
Loading history...
82
     * @param integer        $iDelay                Number of seconds to delay before the redirect occurs
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter type; 8 found
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter name; 16 found
Loading history...
83
     *
84
     * @return Response
0 ignored issues
show
Documentation introduced by
Should the return type not be JsCommands?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
85
     */
86
    public function redirect($sURL, $iDelay = 0)
87
    {
88
        // we need to parse the query part so that the values are rawurlencode()'ed
89
        // can't just use parse_url() cos we could be dealing with a relative URL which
90
        // parse_url() can't deal with.
91
        $queryStart = strpos($sURL, '?', strrpos($sURL, '/'));
92
        if($queryStart !== false)
93
        {
94
            $queryStart++;
95
            $queryEnd = strpos($sURL, '#', $queryStart);
96
            if($queryEnd === false)
97
            {
98
                $queryEnd = strlen($sURL);
99
            }
100
            $queryPart = substr($sURL, $queryStart, $queryEnd - $queryStart);
101
            parse_str($queryPart, $queryParts);
102
            $newQueryPart = "";
103
            if($queryParts)
104
            {
105
                $first = true;
106
                foreach($queryParts as $key => $value)
107
                {
108
                    if($first)
109
                    {
110
                        $first = false;
111
                    }
112
                    else
113
                    {
114
                        $newQueryPart .= '&';
115
                    }
116
                    $newQueryPart .= rawurlencode($key) . '=' . rawurlencode($value);
117
                }
118
            }
119
            elseif($_SERVER['QUERY_STRING'])
120
            {
121
                //couldn't break up the query, but there's one there
122
                //possibly "http://url/page.html?query1234" type of query?
123
                //just encode it and hope it works
124
                $newQueryPart = rawurlencode($_SERVER['QUERY_STRING']);
125
            }
126
            $sURL = str_replace($queryPart, $newQueryPart, $sURL);
0 ignored issues
show
Coding Style introduced by
Consider using a different name than the parameter $sURL. This often makes code more readable.
Loading history...
127
        }
128
        if($iDelay)
129
        {
130
            $this->script('window.setTimeout("window.location = \'' . $sURL . '\';",' . ($iDelay * 1000) . ');');
131
        }
132
        else
133
        {
134
            $this->script('window.location = "' . $sURL . '";');
135
        }
136
        return $this;
137
    }
138
139
    /**
140
     * Add a command to execute a portion of javascript on the browser
141
     *
142
     * The script runs in it's own context, so variables declared locally, using the 'var' keyword,
143
     * will no longer be available after the call.
144
     * To construct a variable that will be accessable globally, even after the script has executed,
145
     * leave off the 'var' keyword.
146
     *
147
     * @param string        $sJS                The script to execute
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter type; 8 found
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter name; 16 found
Loading history...
148
     *
149
     * @return Response
150
     */
151
    public function script($sJS)
152
    {
153
        return $this->_addCommand('js', [], $sJS);
154
    }
155
156
    /**
157
     * Add a command to call the specified javascript function with the given (optional) parameters
158
     *
159
     * @param string        $sFunc                The name of the function to call
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter type; 8 found
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter name; 16 found
Loading history...
160
     *
161
     * @return Response
162
     */
163
    public function call($sFunc)
164
    {
165
        $aArgs = func_get_args();
166
        array_shift($aArgs);
167
        $aAttributes = ['cmd' => 'jc', 'func' => $sFunc];
168
        return $this->addCommand($aAttributes, $aArgs);
169
    }
170
171
    /**
172
     * Add a command to set an event handler on the browser
173
     *
174
     * @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 type; 8 found
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter name; 12 found
Loading history...
175
     * @param string        $sEvent             The name of the event
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter type; 8 found
Loading history...
Coding Style introduced by
Expected 2 spaces after parameter name; 13 found
Loading history...
176
     * @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 type; 8 found
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter name; 12 found
Loading history...
177
     *
178
     * @return Response
179
     */
180
    public function setEvent($sTarget, $sEvent, $sScript)
181
    {
182
        $aAttributes = [
183
            'id' => $sTarget,
184
            'prop' => $sEvent
185
        ];
186
        return $this->_addCommand('ev', $aAttributes, $sScript);
187
    }
188
189
    /**
190
     * Add a command to set a click handler on the browser
191
     *
192
     * @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 type; 8 found
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter name; 12 found
Loading history...
193
     * @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 type; 8 found
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter name; 12 found
Loading history...
194
     *
195
     * @return Response
196
     */
197
    public function onClick($sTarget, $sScript)
198
    {
199
        return $this->setEvent($sTarget, 'onclick', $sScript);
200
    }
201
202
    /**
203
     * Add a command to install an event handler on the specified element
204
     *
205
     * You can add more than one event handler to an element's event using this method.
206
     *
207
     * @param string        $sTarget             The id of the element
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter type; 8 found
Loading history...
Coding Style introduced by
Expected 2 spaces after parameter name; 13 found
Loading history...
208
     * @param string        $sEvent              The name of the event
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter type; 8 found
Loading history...
Coding Style introduced by
Expected 3 spaces after parameter name; 14 found
Loading history...
209
     * @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 type; 8 found
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter name; 12 found
Loading history...
210
     *
211
     * @return Response
212
     */
213
    public function addHandler($sTarget, $sEvent, $sHandler)
214
    {
215
        $aAttributes = [
216
            'id' => $sTarget,
217
            'prop' => $sEvent
218
        ];
219
        return $this->_addCommand('ah', $aAttributes, $sHandler);
220
    }
221
222
    /**
223
     * Add a command to remove an event handler from an element
224
     *
225
     * @param string        $sTarget             The id of the element
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter type; 8 found
Loading history...
Coding Style introduced by
Expected 2 spaces after parameter name; 13 found
Loading history...
226
     * @param string        $sEvent              The name of the event
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter type; 8 found
Loading history...
Coding Style introduced by
Expected 3 spaces after parameter name; 14 found
Loading history...
227
     * @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 type; 8 found
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter name; 12 found
Loading history...
228
     *
229
     * @return Response
230
     */
231
    public function removeHandler($sTarget, $sEvent, $sHandler)
232
    {
233
        $aAttributes = [
234
            'id' => $sTarget,
235
            'prop' => $sEvent
236
        ];
237
        return $this->_addCommand('rh', $aAttributes, $sHandler);
238
    }
239
240
    /**
241
     * Add a command to construct a javascript function on the browser
242
     *
243
     * @param string        $sFunction            The name of the function to construct
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter type; 8 found
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter name; 12 found
Loading history...
244
     * @param string        $sArgs                Comma separated list of parameter names
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter type; 8 found
Loading history...
Coding Style introduced by
Expected 5 spaces after parameter name; 16 found
Loading history...
245
     * @param string        $sScript            The javascript code that will become the body of the function
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter type; 8 found
Loading history...
Coding Style introduced by
Expected 3 spaces after parameter name; 12 found
Loading history...
246
     *
247
     * @return Response
248
     */
249
    public function setFunction($sFunction, $sArgs, $sScript)
250
    {
251
        $aAttributes = [
252
            'func' => $sFunction,
253
            'prop' => $sArgs
254
        ];
255
        return $this->_addCommand('sf', $aAttributes, $sScript);
256
    }
257
258
    /**
259
     * Add a command to construct a wrapper function around an existing javascript function on the browser
260
     *
261
     * @param string        $sFunction            The name of the existing function to wrap
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter type; 8 found
Loading history...
Coding Style introduced by
Expected 7 spaces after parameter name; 12 found
Loading history...
262
     * @param string        $sArgs                The comma separated list of parameters for the function
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter type; 8 found
Loading history...
Coding Style introduced by
Expected 11 spaces after parameter name; 16 found
Loading history...
263
     * @param array            $aScripts            An array of javascript code snippets that will be used to build
0 ignored issues
show
Coding Style introduced by
Expected 2 spaces after parameter type; 12 found
Loading history...
Coding Style introduced by
Expected 8 spaces after parameter name; 12 found
Loading history...
264
     *                                             the body of the function
0 ignored issues
show
Coding Style introduced by
Parameter comment not aligned correctly; expected 46 spaces but found 45
Loading history...
265
     *                                             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 46 spaces but found 45
Loading history...
266
     *                                             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 46 spaces but found 45
Loading history...
267
     *                                             the original function is called.
0 ignored issues
show
Coding Style introduced by
Parameter comment not aligned correctly; expected 46 spaces but found 45
Loading history...
268
     * @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 type; 8 found
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter name; 4 found
Loading history...
269
     *                                             from the call to the original function
0 ignored issues
show
Coding Style introduced by
Parameter comment not aligned correctly; expected 42 spaces but found 45
Loading history...
270
     *
271
     * @return Response
272
     */
273
    public function wrapFunction($sFunction, $sArgs, $aScripts, $sReturnValueVar)
274
    {
275
        $aAttributes = [
276
            'cmd' => 'wpf',
277
            'func' => $sFunction,
278
            'prop' => $sArgs,
279
            'type' => $sReturnValueVar
280
        ];
281
        return $this->addCommand($aAttributes, $aScripts);
282
    }
283
284
    /**
285
     * Add a command to load a javascript file on the browser
286
     *
287
     * @param boolean       $bIncludeOnce         Include once or not
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter type; 7 found
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter name; 9 found
Loading history...
288
     * @param string        $sFileName            The relative or fully qualified URI of the javascript file
0 ignored issues
show
Coding Style introduced by
Expected 2 spaces after parameter type; 8 found
Loading history...
Coding Style introduced by
Expected 4 spaces after parameter name; 12 found
Loading history...
289
     * @param string        $sType                Determines the script type. Defaults to 'text/javascript'
0 ignored issues
show
Coding Style introduced by
Expected 2 spaces after parameter type; 8 found
Loading history...
Coding Style introduced by
Expected 8 spaces after parameter name; 16 found
Loading history...
290
     * @param string        $sId                  The wrapper id
0 ignored issues
show
Coding Style introduced by
Expected 2 spaces after parameter type; 8 found
Loading history...
Coding Style introduced by
Expected 10 spaces after parameter name; 18 found
Loading history...
291
     *
292
     * @return Response
293
     */
294
    private function _includeScript($bIncludeOnce, $sFileName, $sType, $sId)
295
    {
296
        $aAttributes = [
297
            'type' => $sType,
298
            'elm_id' => $sId
299
        ];
300
        return $this->_addCommand(($bIncludeOnce ? 'ino' : 'in'), $aAttributes, $sFileName, true);
301
    }
302
303
    /**
304
     * Add a command to load a javascript file on the browser
305
     *
306
     * @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 type; 8 found
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter name; 12 found
Loading history...
307
     * @param string        $sType                Determines the script type. Defaults to 'text/javascript'
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter type; 8 found
Loading history...
Coding Style introduced by
Expected 5 spaces after parameter name; 16 found
Loading history...
308
     * @param string        $sId                  The wrapper id
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter type; 8 found
Loading history...
Coding Style introduced by
Expected 7 spaces after parameter name; 18 found
Loading history...
309
     *
310
     * @return Response
311
     */
312
    public function includeScript($sFileName, $sType = '', $sId = '')
313
    {
314
        return $this->_includeScript(false, $sFileName, $sType, $sId);
315
    }
316
317
    /**
318
     * Add a command to include a javascript file on the browser if it has not already been loaded
319
     *
320
     * @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 type; 8 found
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter name; 12 found
Loading history...
321
     * @param string        $sType                Determines the script type. Defaults to 'text/javascript'
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter type; 8 found
Loading history...
Coding Style introduced by
Expected 5 spaces after parameter name; 16 found
Loading history...
322
     * @param string        $sId                  The wrapper id
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter type; 8 found
Loading history...
Coding Style introduced by
Expected 7 spaces after parameter name; 18 found
Loading history...
323
     *
324
     * @return Response
325
     */
326
    public function includeScriptOnce($sFileName, $sType = '', $sId = '')
327
    {
328
        return $this->_includeScript(true, $sFileName, $sType, $sId);
329
    }
330
331
    /**
332
     * Add a command to remove a SCRIPT reference to a javascript file on the browser
333
     *
334
     * Optionally, you can call a javascript function just prior to the file being unloaded (for cleanup).
335
     *
336
     * @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 type; 8 found
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter name; 12 found
Loading history...
337
     * @param string        $sUnload            Name of a javascript function to call prior to unlaoding the file
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter type; 8 found
Loading history...
Coding Style introduced by
Expected 3 spaces after parameter name; 12 found
Loading history...
338
     *
339
     * @return Response
340
     */
341
    public function removeScript($sFileName, $sUnload = '')
342
    {
343
        $aAttributes = ['unld' => $sUnload];
344
        return $this->_addCommand('rjs', $aAttributes, $sFileName, true);
345
    }
346
347
    /**
348
     * Add a command to include a LINK reference to the specified CSS file on the browser.
349
     *
350
     * This will cause the browser to load and apply the style sheet.
351
     *
352
     * @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 type; 8 found
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter name; 12 found
Loading history...
353
     * @param string        $sMedia                The media type of the CSS file. Defaults to 'screen'
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter type; 8 found
Loading history...
Coding Style introduced by
Expected 4 spaces after parameter name; 16 found
Loading history...
354
     *
355
     * @return Response
356
     */
357
    public function includeCSS($sFileName, $sMedia = '')
358
    {
359
        $aAttributes = ['media' => $sMedia];
360
        return $this->_addCommand('css', $aAttributes, $sFileName, true);
361
    }
362
363
    /**
0 ignored issues
show
Coding Style introduced by
Parameter $sMedia should have a doc-comment as per coding-style.
Loading history...
364
     * Add a command to remove a LINK reference to a CSS file on the browser
365
     *
366
     * This causes the browser to unload the style sheet, effectively removing the style changes it caused.
367
     *
368
     * @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 type; 8 found
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter name; 12 found
Loading history...
369
     *
370
     * @return Response
371
     */
372
    public function removeCSS($sFileName, $sMedia = '')
373
    {
374
        $aAttributes = ['media' => $sMedia];
375
        return $this->_addCommand('rcss', $aAttributes, $sFileName, true);
376
    }
377
378
    /**
379
     * Add a command to make Jaxon pause while the CSS files are loaded
380
     *
381
     * The browser is not typically a multi-threading application, with regards to javascript code.
382
     * Therefore, the CSS files included or removed with <Response->includeCSS> and
383
     * <Response->removeCSS> respectively, will not be loaded or removed until the browser regains
384
     * control from the script.
385
     * This command returns control back to the browser and pauses the execution of the response
386
     * until the CSS files, included previously, are loaded.
387
     *
388
     * @param integer        $iTimeout            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 type; 8 found
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter name; 12 found
Loading history...
389
     *                                             and continuing with the execution of the response commands
0 ignored issues
show
Coding Style introduced by
Parameter comment not aligned correctly; expected 44 spaces but found 45
Loading history...
390
     *
391
     * @return Response
392
     */
393
    public function waitForCSS($iTimeout = 600)
394
    {
395
        $aAttributes = ['cmd' => 'wcss', 'prop' => $iTimeout];
396
        return $this->addCommand($aAttributes, '');
397
    }
398
399
    /**
400
     * Add a command to make Jaxon to delay execution of the response commands until a specified condition is met
401
     *
402
     * Note, this returns control to the browser, so that other script operations can execute.
403
     * Jaxon will continue to monitor the specified condition and, when it evaluates to true,
404
     * will continue processing response commands.
405
     *
406
     * @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; 8 found
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter name; 16 found
Loading history...
407
     * @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 type; 8 found
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter name; 16 found
Loading history...
408
     *                                             and continuing with the execution of the response commands.
0 ignored issues
show
Coding Style introduced by
Parameter comment not aligned correctly; expected 46 spaces but found 45
Loading history...
409
     *
410
     * @return Response
411
     */
412
    public function waitFor($script, $tenths)
413
    {
414
        $aAttributes = ['cmd' => 'wf', 'prop' => $tenths];
415
        return $this->addCommand($aAttributes, $script);
416
    }
417
418
    /**
419
     * Add a command to make Jaxon to pause execution of the response commands,
420
     * returning control to the browser so it can perform other commands asynchronously.
421
     *
422
     * After the specified delay, Jaxon will continue execution of the response commands.
423
     *
424
     * @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 type; 8 found
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter name; 16 found
Loading history...
425
     *
426
     * @return Response
427
     */
428
    public function sleep($tenths)
429
    {
430
        $aAttributes = ['cmd' =>'s', 'prop' => $tenths];
0 ignored issues
show
Coding Style introduced by
Expected 1 space after "=>"; 0 found
Loading history...
431
        return $this->addCommand($aAttributes, '');
432
    }
433
}
434