Passed
Push — v5.x ( 6ac3c7...223ede )
by Thierry
02:17
created

CallFactory::__call()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 6
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
1
<?php
2
0 ignored issues
show
Coding Style introduced by
Missing file doc comment
Loading history...
3
namespace Jaxon\Js;
4
5
/**
0 ignored issues
show
Coding Style introduced by
Block comments must be started with /*
Loading history...
6
 * CallFactory.php
7
 *
8
 * Create Jaxon client side requests, which will generate the client script necessary
9
 * to invoke a jaxon request from the browser to registered objects.
10
 *
11
 * @package jaxon-core
12
 * @author Thierry Feuzeu
13
 * @copyright 2022 Thierry Feuzeu <[email protected]>
14
 * @license https://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License
15
 * @link https://github.com/jaxon-php/jaxon-core
16
 */
17
18
use Jaxon\App\Dialog\DialogManager;
19
20
use function array_shift;
21
use function func_get_args;
22
23
class CallFactory
0 ignored issues
show
Coding Style introduced by
Missing doc comment for class CallFactory
Loading history...
24
{
25
    /**
26
     * @var string
27
     */
28
    protected $sPrefix;
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line(s) before first member var; 0 found
Loading history...
29
30
    /**
31
     * @var DialogManager
32
     */
33
    protected $xDialogManager;
34
35
    /**
36
     * The class constructor
37
     *
38
     * @param string $sPrefix
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected 8 spaces after parameter type; 1 found
Loading history...
39
     * @param DialogManager $xDialogManager
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
40
     */
41
    public function __construct(string $sPrefix, DialogManager $xDialogManager)
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines before function; 1 found
Loading history...
42
    {
43
        $this->sPrefix = $sPrefix;
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...
44
        $this->xDialogManager = $xDialogManager;
45
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
46
47
    /**
48
     * Generate the javascript code for a call to a given method or function
49
     *
50
     * @param string $sFunction
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
51
     * @param array $aArguments
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected 2 spaces after parameter type; 1 found
Loading history...
52
     *
53
     * @return Call
54
     */
55
    public function __call(string $sFunction, array $aArguments): Call
56
    {
57
        $xCall = new Call($this->sPrefix . $sFunction);
58
        $xCall->setDialogManager($this->xDialogManager);
59
        $xCall->addParameters($aArguments);
60
        return $xCall;
61
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
62
63
    /**
64
     * Return the javascript call to a Jaxon function or object method
65
     *
66
     * @param string $sFunction    The function or method (without class) name
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter name; 4 found
Loading history...
67
     *
68
     * @return Call
69
     * @deprecated
70
     */
71
    public function call(string $sFunction): Call
72
    {
73
        $aArguments = func_get_args();
74
        // Remove the function name from the arguments array.
75
        array_shift($aArguments);
76
        return $this->__call($sFunction, $aArguments);
77
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 0 found
Loading history...
78
}
79