Passed
Push — master ( 6eb156...b34d93 )
by Thierry
04:25
created

Call   A

Complexity

Total Complexity 34

Size/Duplication

Total Lines 404
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 89
dl 0
loc 404
rs 9.68
c 1
b 0
f 0
wmc 34

20 Methods

Rating   Name   Duplication   Size   Complexity  
A pg() 0 3 1
A makePhrase() 0 21 4
A ifge() 0 4 1
A iflt() 0 4 1
A setPageNumber() 0 12 3
A getScript() 0 33 5
A elseShow() 0 6 1
A _makeUniqueJsVar() 0 21 3
A ifne() 0 4 1
A makeMessage() 0 7 2
A paginate() 0 3 1
A ifeq() 0 4 1
A when() 0 4 1
A hasPageNumber() 0 10 3
A unless() 0 4 1
A __construct() 0 5 1
A ifgt() 0 4 1
A confirm() 0 7 1
A ifle() 0 4 1
A pages() 0 3 1
1
<?php
2
3
/**
4
 * Call.php - The Jaxon Call
5
 *
6
 * This class is used to create client side 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\Request\Call;
22
23
use Jaxon\Response\Plugin\JQuery\DomSelector;
24
use Jaxon\Ui\Dialogs\DialogFacade;
25
use Jaxon\Ui\Pagination\Paginator;
26
27
use function array_map;
28
use function array_shift;
29
use function func_get_args;
30
use function implode;
31
32
class Call extends JsCall
0 ignored issues
show
Coding Style introduced by
Missing doc comment for class Call
Loading history...
33
{
34
    /**
35
     * @var DialogFacade
36
     */
37
    protected $xDialogFacade;
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line(s) before first member var; 0 found
Loading history...
38
39
    /**
40
     * @var Paginator
41
     */
42
    protected $xPaginator;
43
44
    /**
45
     * A condition to check before sending this request
46
     *
47
     * @var string
48
     */
49
    protected $sCondition = null;
50
51
    /**
52
     * The arguments of the confirm() call
53
     *
54
     * @var array
55
     */
56
    protected $aConfirmArgs = [];
57
58
    /**
59
     * The arguments of the elseShow() call
60
     *
61
     * @var array
62
     */
63
    protected $aMessageArgs = [];
64
65
    /**
66
     * @var array
67
     */
68
    private $aVariables;
69
70
    /**
71
     * @var string
72
     */
73
    private $sVars;
74
75
    /**
76
     * @var int
0 ignored issues
show
Bug introduced by
Expected "integer" but found "int" for @var tag in member variable comment
Loading history...
77
     */
78
    private $nVarId;
79
80
    /**
81
     * The constructor.
82
     *
83
     * @param string $sName    The javascript function or method name
0 ignored issues
show
Coding Style introduced by
Expected 7 spaces after parameter type; 1 found
Loading history...
Coding Style introduced by
Expected 9 spaces after parameter name; 4 found
Loading history...
84
     * @param DialogFacade $xDialogFacade
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
85
     * @param Paginator $xPaginator
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected 4 spaces after parameter type; 1 found
Loading history...
86
     */
87
    public function __construct(string $sName, DialogFacade $xDialogFacade, Paginator $xPaginator)
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines before function; 1 found
Loading history...
88
    {
89
        parent::__construct($sName);
90
        $this->xDialogFacade = $xDialogFacade;
91
        $this->xPaginator = $xPaginator;
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 4 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...
92
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
93
94
    /**
95
     * Add a condition to the request
96
     *
97
     * The request is sent only if the condition is true.
98
     *
99
     * @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...
100
     *
101
     * @return Call
102
     */
103
    public function when($xCondition): Call
104
    {
105
        $this->sCondition = Parameter::make($xCondition)->getScript();
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 condition to the request
111
     *
112
     * The request is sent only if the condition is false.
113
     *
114
     * @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...
115
     *
116
     * @return Call
117
     */
118
    public function unless($xCondition): Call
119
    {
120
        $this->sCondition = '!(' . Parameter::make($xCondition)->getScript() . ')';
121
        return $this;
122
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
123
124
    /**
125
     * Check if a value is equal to another before sending the request
126
     *
127
     * @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...
128
     * @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...
129
     *
130
     * @return Call
131
     */
132
    public function ifeq($xValue1, $xValue2): Call
133
    {
134
        $this->sCondition = Parameter::make($xValue1) . '==' . Parameter::make($xValue2);
0 ignored issues
show
Bug introduced by
Are you sure Jaxon\Request\Call\Parameter::make($xValue2) of type Jaxon\Request\Call\ParameterInterface can be used in concatenation? Consider adding a __toString()-method. ( Ignorable by Annotation )

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

134
        $this->sCondition = Parameter::make($xValue1) . '==' . /** @scrutinizer ignore-type */ Parameter::make($xValue2);
Loading history...
Bug introduced by
Are you sure Jaxon\Request\Call\Parameter::make($xValue1) of type Jaxon\Request\Call\ParameterInterface can be used in concatenation? Consider adding a __toString()-method. ( Ignorable by Annotation )

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

134
        $this->sCondition = /** @scrutinizer ignore-type */ Parameter::make($xValue1) . '==' . Parameter::make($xValue2);
Loading history...
135
        return $this;
136
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
137
138
    /**
139
     * Check if a value is not equal to another before sending the request
140
     *
141
     * @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...
142
     * @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...
143
     *
144
     * @return Call
145
     */
146
    public function ifne($xValue1, $xValue2): Call
147
    {
148
        $this->sCondition = Parameter::make($xValue1) . '!=' . Parameter::make($xValue2);
0 ignored issues
show
Bug introduced by
Are you sure Jaxon\Request\Call\Parameter::make($xValue1) of type Jaxon\Request\Call\ParameterInterface can be used in concatenation? Consider adding a __toString()-method. ( Ignorable by Annotation )

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

148
        $this->sCondition = /** @scrutinizer ignore-type */ Parameter::make($xValue1) . '!=' . Parameter::make($xValue2);
Loading history...
Bug introduced by
Are you sure Jaxon\Request\Call\Parameter::make($xValue2) of type Jaxon\Request\Call\ParameterInterface can be used in concatenation? Consider adding a __toString()-method. ( Ignorable by Annotation )

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

148
        $this->sCondition = Parameter::make($xValue1) . '!=' . /** @scrutinizer ignore-type */ Parameter::make($xValue2);
Loading history...
149
        return $this;
150
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
151
152
    /**
153
     * Check if a value is greater than another before sending the request
154
     *
155
     * @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...
156
     * @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...
157
     *
158
     * @return Call
159
     */
160
    public function ifgt($xValue1, $xValue2): Call
161
    {
162
        $this->sCondition = Parameter::make($xValue1) . '>' . Parameter::make($xValue2);
0 ignored issues
show
Bug introduced by
Are you sure Jaxon\Request\Call\Parameter::make($xValue2) of type Jaxon\Request\Call\ParameterInterface can be used in concatenation? Consider adding a __toString()-method. ( Ignorable by Annotation )

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

162
        $this->sCondition = Parameter::make($xValue1) . '>' . /** @scrutinizer ignore-type */ Parameter::make($xValue2);
Loading history...
Bug introduced by
Are you sure Jaxon\Request\Call\Parameter::make($xValue1) of type Jaxon\Request\Call\ParameterInterface can be used in concatenation? Consider adding a __toString()-method. ( Ignorable by Annotation )

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

162
        $this->sCondition = /** @scrutinizer ignore-type */ Parameter::make($xValue1) . '>' . Parameter::make($xValue2);
Loading history...
163
        return $this;
164
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
165
166
    /**
167
     * Check if a value is greater or equal to another before sending the request
168
     *
169
     * @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...
170
     * @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...
171
     *
172
     * @return Call
173
     */
174
    public function ifge($xValue1, $xValue2): Call
175
    {
176
        $this->sCondition = Parameter::make($xValue1) . '>=' . Parameter::make($xValue2);
0 ignored issues
show
Bug introduced by
Are you sure Jaxon\Request\Call\Parameter::make($xValue1) of type Jaxon\Request\Call\ParameterInterface can be used in concatenation? Consider adding a __toString()-method. ( Ignorable by Annotation )

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

176
        $this->sCondition = /** @scrutinizer ignore-type */ Parameter::make($xValue1) . '>=' . Parameter::make($xValue2);
Loading history...
Bug introduced by
Are you sure Jaxon\Request\Call\Parameter::make($xValue2) of type Jaxon\Request\Call\ParameterInterface can be used in concatenation? Consider adding a __toString()-method. ( Ignorable by Annotation )

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

176
        $this->sCondition = Parameter::make($xValue1) . '>=' . /** @scrutinizer ignore-type */ Parameter::make($xValue2);
Loading history...
177
        return $this;
178
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
179
180
    /**
181
     * Check if a value is lower than another before sending the request
182
     *
183
     * @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...
184
     * @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...
185
     *
186
     * @return Call
187
     */
188
    public function iflt($xValue1, $xValue2): Call
189
    {
190
        $this->sCondition = Parameter::make($xValue1) . '<' . Parameter::make($xValue2);
0 ignored issues
show
Bug introduced by
Are you sure Jaxon\Request\Call\Parameter::make($xValue2) of type Jaxon\Request\Call\ParameterInterface can be used in concatenation? Consider adding a __toString()-method. ( Ignorable by Annotation )

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

190
        $this->sCondition = Parameter::make($xValue1) . '<' . /** @scrutinizer ignore-type */ Parameter::make($xValue2);
Loading history...
Bug introduced by
Are you sure Jaxon\Request\Call\Parameter::make($xValue1) of type Jaxon\Request\Call\ParameterInterface can be used in concatenation? Consider adding a __toString()-method. ( Ignorable by Annotation )

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

190
        $this->sCondition = /** @scrutinizer ignore-type */ Parameter::make($xValue1) . '<' . Parameter::make($xValue2);
Loading history...
191
        return $this;
192
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
193
194
    /**
195
     * Check if a value is lower or equal to another before sending the request
196
     *
197
     * @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...
198
     * @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...
199
     *
200
     * @return Call
201
     */
202
    public function ifle($xValue1, $xValue2): Call
203
    {
204
        $this->sCondition = Parameter::make($xValue1) . '<=' . Parameter::make($xValue2);
0 ignored issues
show
Bug introduced by
Are you sure Jaxon\Request\Call\Parameter::make($xValue1) of type Jaxon\Request\Call\ParameterInterface can be used in concatenation? Consider adding a __toString()-method. ( Ignorable by Annotation )

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

204
        $this->sCondition = /** @scrutinizer ignore-type */ Parameter::make($xValue1) . '<=' . Parameter::make($xValue2);
Loading history...
Bug introduced by
Are you sure Jaxon\Request\Call\Parameter::make($xValue2) of type Jaxon\Request\Call\ParameterInterface can be used in concatenation? Consider adding a __toString()-method. ( Ignorable by Annotation )

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

204
        $this->sCondition = Parameter::make($xValue1) . '<=' . /** @scrutinizer ignore-type */ Parameter::make($xValue2);
Loading history...
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
     * Add a confirmation question to the request
210
     *
211
     * @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...
212
     *
213
     * @return Call
214
     */
215
    public function confirm(string $sQuestion): Call
216
    {
217
        $this->sCondition = '__confirm__';
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 3 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...
218
        $this->aConfirmArgs = array_map(function($xParameter) {
219
            return Parameter::make($xParameter);
220
        }, func_get_args());
221
        return $this;
222
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
223
224
    /**
225
     * Set the message to show if the condition to send the request is not met
226
     *
227
     * The first parameter is the message to show. The followings allow inserting data from
228
     * the webpage in the message using positional placeholders.
229
     *
230
     * @param string $sMessage    The message to show if the request is not sent
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter name; 4 found
Loading history...
231
     *
232
     * @return Call
233
     */
234
    public function elseShow(string $sMessage): Call
235
    {
236
        $this->aMessageArgs = array_map(function($xParameter) {
237
            return Parameter::make($xParameter);
238
        }, func_get_args());
239
        return $this;
240
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
241
242
    /**
243
     * Make unique js vars for parameters of type DomSelector
244
     *
245
     * @param ParameterInterface $xParameter
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
246
     *
247
     * @return ParameterInterface
248
     */
249
    private function _makeUniqueJsVar(ParameterInterface $xParameter): ParameterInterface
250
    {
251
        if($xParameter instanceof DomSelector)
252
        {
253
            $sParameterStr = $xParameter->getScript();
254
            if(!isset($this->aVariables[$sParameterStr]))
255
            {
256
                // The value is not yet defined. A new variable is created.
257
                $sVarName = 'jxnVar' . $this->nVarId;
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 25 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...
258
                $this->aVariables[$sParameterStr] = $sVarName;
259
                $this->sVars .= "$sVarName=$xParameter;";
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 21 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...
260
                $this->nVarId++;
261
            }
262
            else
263
            {
264
                // The value is already defined. The corresponding variable is assigned.
265
                $sVarName = $this->aVariables[$sParameterStr];
266
            }
267
            $xParameter = new Parameter(Parameter::JS_VALUE, $sVarName);
268
        }
269
        return $xParameter;
270
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
271
272
    /**
273
     * Make a phrase to be displayed in js code
274
     *
275
     * @param array $aArgs
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
276
     *
277
     * @return string
278
     */
279
    private function makePhrase(array $aArgs): string
280
    {
281
        if(empty($aArgs))
282
        {
283
            return '';
284
        }
285
        // The first array entry is the message.
286
        $sPhrase = array_shift($aArgs);
287
        if(empty($aArgs))
288
        {
289
            return $sPhrase;
290
        }
291
        $nParamId = 1;
292
        foreach($aArgs as &$xParameter)
293
        {
294
            $xParameter = $this->_makeUniqueJsVar($xParameter);
295
            $xParameter = "'$nParamId':" . $xParameter->getScript();
296
            $nParamId++;
297
        }
298
        $sPhrase .= '.supplant({' . implode(',', $aArgs) . '})';
299
        return $sPhrase;
300
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
301
302
    /**
303
     * Make a phrase to be displayed in js code
304
     *
305
     * @param array $aArgs
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
306
     *
307
     * @return string
308
     */
309
    private function makeMessage(array $aArgs): string
310
    {
311
        if(!($sPhrase = $this->makePhrase($aArgs)))
0 ignored issues
show
Coding Style introduced by
Variable assignment found within a condition. Did you mean to do a comparison ?
Loading history...
312
        {
313
            return '';
314
        }
315
        return $this->xDialogFacade->getMessageLibrary(true)->warning($sPhrase);
316
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
317
318
    /**
319
     * Returns a string representation of the script output (javascript) from this request object
320
     *
321
     * @return string
322
     */
323
    public function getScript(): string
324
    {
325
        /*
326
         * JQuery variables sometimes depend on the context where they are used, eg. when their value depends on $(this).
327
         * When a confirmation question is added, the Jaxon calls are made in a different context,
328
         * making those variables invalid.
329
         * To avoid issues related to these context changes, the JQuery selectors values are first saved into
330
         * local variables, which are then used in Jaxon function calls.
331
         */
0 ignored issues
show
Coding Style introduced by
Empty line required after block comment
Loading history...
332
        $this->sVars = ''; // Javascript code defining all the variables values.
333
        $this->nVarId = 1; // Position of the variables, starting from 1.
334
        // This array will avoid declaring multiple variables with the same value.
335
        // The array key is the variable value, while the array value is the variable name.
336
        $this->aVariables = []; // Array of local variables.
337
        foreach($this->aParameters as &$xParameter)
338
        {
339
            $xParameter = $this->_makeUniqueJsVar($xParameter);
340
        }
341
342
        $sMessageScript = $this->makeMessage($this->aMessageArgs);
343
        $sScript = parent::getScript();
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 8 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...
344
        if($this->sCondition === '__confirm__')
345
        {
346
            $sConfirmPhrase = $this->makePhrase($this->aConfirmArgs);
347
            $sScript = $this->xDialogFacade->getQuestionLibrary()
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 8 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...
348
                ->confirm($sConfirmPhrase, $sScript, $sMessageScript);
0 ignored issues
show
Coding Style introduced by
Space found before object operator
Loading history...
349
        }
350
        elseif($this->sCondition !== null)
351
        {
352
            $sScript = empty($sMessageScript) ? 'if(' . $this->sCondition . '){' . $sScript . ';}' :
0 ignored issues
show
Coding Style introduced by
Expected 1 space after ":"; newline found
Loading history...
353
                'if(' . $this->sCondition . '){' . $sScript . ';}else{' . $sMessageScript . ';}';
354
        }
355
        return $this->sVars . $sScript;
356
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
357
358
    /**
359
     * Check if the request has a parameter of type Parameter::PAGE_NUMBER
360
     *
361
     * @return bool
362
     */
363
    public function hasPageNumber(): bool
364
    {
365
        foreach($this->aParameters as $xParameter)
366
        {
367
            if($xParameter->getType() === Parameter::PAGE_NUMBER)
368
            {
369
                return true;
370
            }
371
        }
372
        return false;
373
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
374
375
    /**
376
     * Set a value to the Parameter::PAGE_NUMBER parameter
377
     *
378
     * @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...
379
     *
380
     * @return Call
381
     */
382
    public function setPageNumber(int $nPageNumber): Call
383
    {
384
        // Set the value of the Parameter::PAGE_NUMBER parameter
385
        foreach($this->aParameters as $xParameter)
386
        {
387
            if($xParameter->getType() === Parameter::PAGE_NUMBER)
388
            {
389
                $xParameter->setValue($nPageNumber);
390
                break;
391
            }
392
        }
393
        return $this;
394
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
395
396
    /**
397
     * Make the pagination links for this request
398
     *
399
     * @param integer $nCurrentPage    The current page
0 ignored issues
show
Coding Style introduced by
Expected 2 spaces after parameter name; 4 found
Loading history...
400
     * @param integer $nItemsPerPage    The number of items per page
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter name; 4 found
Loading history...
401
     * @param integer $nItemsTotal    The total number of items
0 ignored issues
show
Coding Style introduced by
Expected 3 spaces after parameter name; 4 found
Loading history...
402
     *
403
     * @return Paginator
404
     */
405
    public function paginate(int $nCurrentPage, int $nItemsPerPage, int $nItemsTotal): Paginator
406
    {
407
        return $this->xPaginator->setup($this, $nCurrentPage, $nItemsPerPage, $nItemsTotal);
408
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
409
410
    /**
411
     * Make the pagination links for this request
412
     *
413
     * @param integer $nCurrentPage    The current page
0 ignored issues
show
Coding Style introduced by
Expected 2 spaces after parameter name; 4 found
Loading history...
414
     * @param integer $nItemsPerPage    The number of items per page
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter name; 4 found
Loading history...
415
     * @param integer $nItemsTotal    The total number of items
0 ignored issues
show
Coding Style introduced by
Expected 3 spaces after parameter name; 4 found
Loading history...
416
     *
417
     * @return Paginator
418
     */
419
    public function pg(int $nCurrentPage, int $nItemsPerPage, int $nItemsTotal): Paginator
420
    {
421
        return $this->paginate($nCurrentPage, $nItemsPerPage, $nItemsTotal);
422
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
423
424
    /**
425
     * Make the pagination links for this request
426
     *
427
     * @param integer $nCurrentPage    The current page
0 ignored issues
show
Coding Style introduced by
Expected 2 spaces after parameter name; 4 found
Loading history...
428
     * @param integer $nItemsPerPage    The number of items per page
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter name; 4 found
Loading history...
429
     * @param integer $nItemsTotal    The total number of items
0 ignored issues
show
Coding Style introduced by
Expected 3 spaces after parameter name; 4 found
Loading history...
430
     *
431
     * @return array
432
     */
433
    public function pages(int $nCurrentPage, int $nItemsPerPage, int $nItemsTotal): array
434
    {
435
        return $this->xPaginator->setup($this, $nCurrentPage, $nItemsPerPage, $nItemsTotal)->getPages();
436
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 0 found
Loading history...
437
}
438