Passed
Push — v5.x ( 223ede...01c17e )
by Thierry
02:01
created

Call::raw()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 7
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 0
1
<?php
2
3
/**
4
 * Call.php - The Jaxon Call
5
 *
6
 * This class is used to create js ajax requests to callable classes and functions.
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 Jared White
0 ignored issues
show
Coding Style introduced by
Content of the @author tag must be in the form "Display Name <[email protected]>"
Loading history...
10
 * @author J. Max Wilson
0 ignored issues
show
Coding Style introduced by
Content of the @author tag must be in the form "Display Name <[email protected]>"
Loading history...
11
 * @author Joseph Woolley
0 ignored issues
show
Coding Style introduced by
Content of the @author tag must be in the form "Display Name <[email protected]>"
Loading history...
12
 * @author Steffen Konerow
0 ignored issues
show
Coding Style introduced by
Content of the @author tag must be in the form "Display Name <[email protected]>"
Loading history...
13
 * @author Thierry Feuzeu <[email protected]>
14
 * @copyright Copyright (c) 2005-2007 by Jared White & J. Max Wilson
0 ignored issues
show
Coding Style introduced by
@copyright tag must contain a year and the name of the copyright holder
Loading history...
15
 * @copyright Copyright (c) 2008-2010 by Joseph Woolley, Steffen Konerow, Jared White  & J. Max Wilson
0 ignored issues
show
Coding Style introduced by
@copyright tag must contain a year and the name of the copyright holder
Loading history...
16
 * @copyright 2016 Thierry Feuzeu <[email protected]>
17
 * @license https://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License
18
 * @link https://github.com/jaxon-php/jaxon-core
19
 */
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...
20
21
namespace Jaxon\Js;
22
23
use Jaxon\App\Dialog\DialogManager;
24
use JsonSerializable;
25
use Stringable;
26
27
use function array_map;
28
use function array_shift;
29
use function func_get_args;
30
use function implode;
31
use function json_encode;
32
33
class Call implements JsonSerializable, Stringable
0 ignored issues
show
Coding Style introduced by
Missing doc comment for class Call
Loading history...
34
{
35
    use Traits\ToInt;
36
37
    /**
38
     * @var DialogManager
39
     */
40
    protected $xDialogManager;
41
42
    /**
43
     * The name of the javascript function
44
     *
45
     * @var string
46
     */
47
    private $sFunction;
48
49
    /**
50
     * @var array<ParameterInterface>
51
     */
52
    protected $aParameters = [];
53
54
    /**
55
     * The arguments of the else() calls
56
     *
57
     * @var array
58
     */
59
    protected $aMessage = [];
60
61
    /**
62
     * A condition to check before making the call
63
     *
64
     * @var array
65
     */
66
    protected $aCondition = [];
67
68
    /**
69
     * The arguments of the confirm() call
70
     *
71
     * @var array
72
     */
73
    protected $aConfirm = [];
74
75
    /**
76
     * The constructor.
77
     *
78
     * @param string $sFunction    The javascript function
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter name; 4 found
Loading history...
79
     */
80
    public function __construct(string $sFunction)
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines before function; 1 found
Loading history...
81
    {
82
        $this->sFunction = $sFunction;
83
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
84
85
    /**
86
     * Clear the parameter list associated with this request
87
     *
88
     * @return Call
89
     */
90
    public function clearParameters(): Call
91
    {
92
        $this->aParameters = [];
93
        return $this;
94
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
95
96
    /**
97
     * Set the value of the parameter at the given position
98
     *
99
     * @param ParameterInterface $xParameter    The value to be used
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter name; 4 found
Loading history...
100
     *
101
     * @return Call
102
     */
103
    public function pushParameter(ParameterInterface $xParameter): Call
104
    {
105
        $this->aParameters[] = $xParameter;
106
        return $this;
107
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
108
109
    /**
110
     * Add a parameter value to the parameter list for this request
111
     *
112
     * @param string $sType    The type of the value to be used
0 ignored issues
show
Coding Style introduced by
Expected 2 spaces after parameter name; 4 found
Loading history...
113
     * @param string $sValue    The value to be used
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter name; 4 found
Loading history...
114
     *
115
     * Types should be one of the following <Parameter::FORM_VALUES>, <Parameter::QUOTED_VALUE>, <Parameter::NUMERIC_VALUE>,
0 ignored issues
show
Coding Style introduced by
Parameter comment not aligned correctly; expected 26 spaces but found 1
Loading history...
116
     * <Parameter::JS_VALUE>, <Parameter::INPUT_VALUE>, <Parameter::CHECKED_VALUE>, <Parameter::PAGE_NUMBER>.
0 ignored issues
show
Coding Style introduced by
Parameter comment not aligned correctly; expected 26 spaces but found 1
Loading history...
117
     * The value should be as follows:
0 ignored issues
show
Coding Style introduced by
Parameter comment not aligned correctly; expected 26 spaces but found 1
Loading history...
118
     * - <Parameter::FORM_VALUES> - Use the ID of the form you want to process.
0 ignored issues
show
Coding Style introduced by
Parameter comment not aligned correctly; expected 26 spaces but found 1
Loading history...
119
     * - <Parameter::QUOTED_VALUE> - The string data to be passed.
0 ignored issues
show
Coding Style introduced by
Parameter comment not aligned correctly; expected 26 spaces but found 1
Loading history...
120
     * - <Parameter::JS_VALUE> - A string containing valid javascript
0 ignored issues
show
Coding Style introduced by
Parameter comment not aligned correctly; expected 26 spaces but found 1
Loading history...
121
     *   (either a javascript variable name that will be in scope at the time of the call or
0 ignored issues
show
Coding Style introduced by
Parameter comment not aligned correctly; expected 26 spaces but found 3
Loading history...
122
     *   a javascript function call whose return value will become the parameter).
0 ignored issues
show
Coding Style introduced by
Parameter comment not aligned correctly; expected 26 spaces but found 3
Loading history...
123
     *
124
     * @return Call
125
     */
126
    public function addParameter(string $sType, string $sValue): Call
127
    {
128
        $this->pushParameter(new Parameter($sType, $sValue));
129
        return $this;
130
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
131
132
    /**
133
     * Add a set of parameters to this request
134
     *
135
     * @param array $aParameters    The parameters
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter name; 4 found
Loading history...
136
     *
137
     * @return Call
138
     */
139
    public function addParameters(array $aParameters): Call
140
    {
141
        foreach($aParameters as $xParameter)
142
        {
143
            $this->pushParameter(Parameter::make($xParameter));
144
        }
145
        return $this;
146
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
147
148
    /**
149
     * @param array $aArgs
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
150
     *
151
     * @return array
152
     */
153
    private function getArgs(array $aArgs): array
154
    {
155
        array_shift($aArgs);
156
        return $aArgs;
157
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
158
159
    /**
160
     * @param DialogManager $xDialogManager
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
161
     *
162
     * @return void
163
     */
164
    public function setDialogManager(DialogManager $xDialogManager)
165
    {
166
        $this->xDialogManager = $xDialogManager;
167
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
168
169
    /**
170
     * Show a message if the condition to the call is not met
171
     *
172
     * @param string $sMessage  The message to show
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter name; 2 found
Loading history...
173
     *
174
     * @return Call
175
     */
176
    public function elseShow(string $sMessage): Call
177
    {
178
        $this->aMessage = $this->xDialogManager->warning($sMessage, $this->getArgs(func_get_args()));
179
        return $this;
180
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
181
182
    /**
183
     * Show an information message if the condition to the call is not met
184
     *
185
     * @param string $sMessage  The message to show
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter name; 2 found
Loading history...
186
     *
187
     * @return Call
188
     */
189
    public function elseInfo(string $sMessage): Call
190
    {
191
        $this->aMessage = $this->xDialogManager->info($sMessage, $this->getArgs(func_get_args()));
192
        return $this;
193
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
194
195
    /**
196
     * Show a success message if the condition to the call is not met
197
     *
198
     * @param string $sMessage  The message to show
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter name; 2 found
Loading history...
199
     *
200
     * @return Call
201
     */
202
    public function elseSuccess(string $sMessage): Call
203
    {
204
        $this->aMessage = $this->xDialogManager->success($sMessage, $this->getArgs(func_get_args()));
205
        return $this;
206
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
207
208
    /**
209
     * Show a warning message if the condition to the call is not met
210
     *
211
     * @param string $sMessage  The message to show
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter name; 2 found
Loading history...
212
     *
213
     * @return Call
214
     */
215
    public function elseWarning(string $sMessage): Call
216
    {
217
        $this->aMessage = $this->xDialogManager->warning($sMessage, $this->getArgs(func_get_args()));
218
        return $this;
219
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
220
221
    /**
222
     * Show an error message if the condition to the call is not met
223
     *
224
     * @param string $sMessage  The message to show
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter name; 2 found
Loading history...
225
     *
226
     * @return Call
227
     */
228
    public function elseError(string $sMessage): Call
229
    {
230
        $this->aMessage = $this->xDialogManager->error($sMessage, $this->getArgs(func_get_args()));
231
        return $this;
232
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
233
234
    /**
235
     * Add a confirmation question to the request
236
     *
237
     * @param string $sQuestion    The question to ask
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter name; 4 found
Loading history...
238
     *
239
     * @return Call
240
     */
241
    public function confirm(string $sQuestion): Call
242
    {
243
        $this->aConfirm = $this->xDialogManager->confirm($sQuestion, $this->getArgs(func_get_args()));
244
        return $this;
245
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
246
247
    /**
248
     * Check if a value is equal to another before sending the request
249
     *
250
     * @param mixed $xValue1    The first value to compare
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter name; 4 found
Loading history...
251
     * @param mixed $xValue2    The second value to compare
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter name; 4 found
Loading history...
252
     *
253
     * @return Call
254
     */
255
    public function ifeq($xValue1, $xValue2): Call
256
    {
257
        $this->aCondition = ['eq', Parameter::make($xValue1), Parameter::make($xValue2)];
258
        return $this;
259
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
260
261
    /**
262
     * Check if a value is equal to another before sending the request
263
     *
264
     * @param mixed $xValue1    The first value to compare
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter name; 4 found
Loading history...
265
     * @param mixed $xValue2    The second value to compare
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter name; 4 found
Loading history...
266
     *
267
     * @return Call
268
     */
269
    public function ifteq($xValue1, $xValue2): Call
270
    {
271
        $this->aCondition = ['teq', Parameter::make($xValue1), Parameter::make($xValue2)];
272
        return $this;
273
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
274
275
    /**
276
     * Check if a value is not equal to another before sending the request
277
     *
278
     * @param mixed $xValue1    The first value to compare
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter name; 4 found
Loading history...
279
     * @param mixed $xValue2    The second value to compare
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter name; 4 found
Loading history...
280
     *
281
     * @return Call
282
     */
283
    public function ifne($xValue1, $xValue2): Call
284
    {
285
        $this->aCondition = ['ne', Parameter::make($xValue1), Parameter::make($xValue2)];
286
        return $this;
287
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
288
289
    /**
290
     * Check if a value is not equal to another before sending the request
291
     *
292
     * @param mixed $xValue1    The first value to compare
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter name; 4 found
Loading history...
293
     * @param mixed $xValue2    The second value to compare
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter name; 4 found
Loading history...
294
     *
295
     * @return Call
296
     */
297
    public function ifnte($xValue1, $xValue2): Call
298
    {
299
        $this->aCondition = ['nte', Parameter::make($xValue1), Parameter::make($xValue2)];
300
        return $this;
301
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
302
303
    /**
304
     * Check if a value is greater than another before sending the request
305
     *
306
     * @param mixed $xValue1    The first value to compare
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter name; 4 found
Loading history...
307
     * @param mixed $xValue2    The second value to compare
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter name; 4 found
Loading history...
308
     *
309
     * @return Call
310
     */
311
    public function ifgt($xValue1, $xValue2): Call
312
    {
313
        $this->aCondition = ['gt', Parameter::make($xValue1), Parameter::make($xValue2)];
314
        return $this;
315
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
316
317
    /**
318
     * Check if a value is greater or equal to another before sending the request
319
     *
320
     * @param mixed $xValue1    The first value to compare
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter name; 4 found
Loading history...
321
     * @param mixed $xValue2    The second value to compare
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter name; 4 found
Loading history...
322
     *
323
     * @return Call
324
     */
325
    public function ifge($xValue1, $xValue2): Call
326
    {
327
        $this->aCondition = ['ge', Parameter::make($xValue1), Parameter::make($xValue2)];
328
        return $this;
329
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
330
331
    /**
332
     * Check if a value is lower than another before sending the request
333
     *
334
     * @param mixed $xValue1    The first value to compare
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter name; 4 found
Loading history...
335
     * @param mixed $xValue2    The second value to compare
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter name; 4 found
Loading history...
336
     *
337
     * @return Call
338
     */
339
    public function iflt($xValue1, $xValue2): Call
340
    {
341
        $this->aCondition = ['lt', Parameter::make($xValue1), Parameter::make($xValue2)];
342
        return $this;
343
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
344
345
    /**
346
     * Check if a value is lower or equal to another before sending the request
347
     *
348
     * @param mixed $xValue1    The first value to compare
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter name; 4 found
Loading history...
349
     * @param mixed $xValue2    The second value to compare
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter name; 4 found
Loading history...
350
     *
351
     * @return Call
352
     */
353
    public function ifle($xValue1, $xValue2): Call
354
    {
355
        $this->aCondition = ['le', Parameter::make($xValue1), Parameter::make($xValue2)];
356
        return $this;
357
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
358
359
    /**
360
     * Add a condition to the request
361
     *
362
     * The request is sent only if the condition is true.
363
     *
364
     * @param mixed $xCondition    The condition to check
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter name; 4 found
Loading history...
365
     *
366
     * @return Call
367
     */
368
    public function when($xCondition): Call
369
    {
370
        return $this->ifeq(true, $xCondition);
371
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
372
373
    /**
374
     * Add a condition to the request
375
     *
376
     * The request is sent only if the condition is false.
377
     *
378
     * @param mixed $xCondition    The condition to check
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter name; 4 found
Loading history...
379
     *
380
     * @return Call
381
     */
382
    public function unless($xCondition): Call
383
    {
384
        return $this->ifeq(false, $xCondition);
385
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
386
387
    /**
388
     * Check if the request has a parameter of type Parameter::PAGE_NUMBER
389
     *
390
     * @return ParameterInterface|null
391
     */
392
    private function findPageNumber(): ?ParameterInterface
393
    {
394
        foreach($this->aParameters as $xParameter)
395
        {
396
            if($xParameter->getType() === Parameter::PAGE_NUMBER)
397
            {
398
                return $xParameter;
399
            }
400
        }
401
        return null;
402
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
403
404
    /**
405
     * Check if the request has a parameter of type Parameter::PAGE_NUMBER
406
     *
407
     * @return bool
408
     */
409
    public function hasPageNumber(): bool
410
    {
411
        return $this->findPageNumber() !== null;
412
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
413
414
    /**
415
     * Set a value to the Parameter::PAGE_NUMBER parameter
416
     *
417
     * @param integer $nPageNumber    The current page number
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter name; 4 found
Loading history...
418
     *
419
     * @return Call
420
     */
421
    public function setPageNumber(int $nPageNumber): Call
422
    {
423
        /** @var Parameter */
0 ignored issues
show
Coding Style introduced by
Block comments must be started with /*
Loading history...
424
        $xParameter = $this->findPageNumber();
425
        if($xParameter !== null)
426
        {
427
            $xParameter->setValue($nPageNumber);
0 ignored issues
show
Bug introduced by
The method setValue() does not exist on Jaxon\Js\ParameterInterface. Since it exists in all sub-types, consider adding an abstract or default implementation to Jaxon\Js\ParameterInterface. ( Ignorable by Annotation )

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

427
            $xParameter->/** @scrutinizer ignore-call */ 
428
                         setValue($nPageNumber);
Loading history...
428
        }
429
        return $this;
430
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
431
432
    /**
433
     * Convert the first call to array
434
     *
435
     * @return array
436
     */
437
    public function toArray(): array
438
    {
439
        return [
440
            '_type' => 'func',
441
            '_name' => $this->sFunction,
442
            'args' => array_map(function(JsonSerializable $xParam) {
443
                return $xParam->jsonSerialize();
444
            }, $this->aParameters),
445
        ];
446
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
447
448
    /**
449
     * Convert this call to array, when converting the response into json.
450
     *
451
     * @return array
452
     */
453
    public function jsonSerialize(): array
454
    {
455
        $aCalls = [$this->toArray()];
456
        if($this->bToInt)
457
        {
458
            $aCalls[] = $this->toIntCall();
459
        }
460
461
        $aExpr = ['_type' => 'expr', 'calls' => $aCalls];
462
        if(($this->aConfirm))
0 ignored issues
show
Bug Best Practice introduced by
The expression $this->aConfirm of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.

This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.

Consider making the comparison explicit by using empty(..) or ! empty(...) instead.

Loading history...
463
        {
464
            $aExpr['question'] = $this->aConfirm;
465
        }
466
        if(($this->aCondition))
0 ignored issues
show
Bug Best Practice introduced by
The expression $this->aCondition of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.

This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.

Consider making the comparison explicit by using empty(..) or ! empty(...) instead.

Loading history...
467
        {
468
            $aExpr['condition'] = $this->aCondition;
469
        }
470
        if(($this->aMessage))
0 ignored issues
show
Bug Best Practice introduced by
The expression $this->aMessage of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.

This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.

Consider making the comparison explicit by using empty(..) or ! empty(...) instead.

Loading history...
471
        {
472
            $aExpr['message'] = $this->aMessage;
473
        }
474
475
        return $aExpr;
476
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
477
478
    /**
479
     * Returns a call to jaxon as a string
480
     *
481
     * @return string
482
     */
483
    public function __toString(): string
484
    {
485
        return 'jaxon.exec(' . json_encode($this->jsonSerialize()) . ')';
486
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
487
488
    /**
489
     * Returns the js code of the call
490
     *
491
     * @return string
492
     */
493
    public function raw(): string
494
    {
495
        $aParameters = array_map(function(Stringable $xParam) {
496
            return $xParam->__toString();
497
        }, $this->aParameters);
498
        $sScript = $this->sFunction . '(' . implode(', ', $aParameters) . ')';
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 5 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
499
        return $this->bToInt ? "parseInt($sScript)" : $sScript;
500
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 0 found
Loading history...
501
}
502