Passed
Push — v5.x ( fe38d4...6ac3c7 )
by Thierry
10:27
created

JsCallFactory::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
c 0
b 0
f 0
dl 0
loc 4
rs 10
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\Request\Factory;
4
5
/**
0 ignored issues
show
Coding Style introduced by
Block comments must be started with /*
Loading history...
6
 * JsCallFactory.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
use Jaxon\Request\Js\Call;
20
21
use function array_shift;
22
use function func_get_args;
23
24
class JsCallFactory
0 ignored issues
show
Coding Style introduced by
Missing doc comment for class JsCallFactory
Loading history...
25
{
26
    /**
27
     * @var string
28
     */
29
    protected $sPrefix;
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line(s) before first member var; 0 found
Loading history...
30
31
    /**
32
     * @var DialogManager
33
     */
34
    protected $xDialogManager;
35
36
    /**
37
     * The class constructor
38
     *
39
     * @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...
40
     * @param DialogManager $xDialogManager
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
41
     */
42
    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...
43
    {
44
        $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...
45
        $this->xDialogManager = $xDialogManager;
46
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
47
48
    /**
49
     * Generate the javascript code for a call to a given method or function
50
     *
51
     * @param string $sFunction
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
52
     * @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...
53
     *
54
     * @return Call
55
     */
56
    public function __call(string $sFunction, array $aArguments): Call
57
    {
58
        $xCall = new Call($this->sPrefix . $sFunction);
59
        $xCall->setDialogManager($this->xDialogManager);
60
        $xCall->addParameters($aArguments);
61
        return $xCall;
62
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
63
64
    /**
65
     * Return the javascript call to a Jaxon function or object method
66
     *
67
     * @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...
68
     *
69
     * @return Call
70
     * @deprecated
71
     */
72
    public function call(string $sFunction): Call
73
    {
74
        $aArguments = func_get_args();
75
        // Remove the function name from the arguments array.
76
        array_shift($aArguments);
77
        return $this->__call($sFunction, $aArguments);
78
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 0 found
Loading history...
79
}
80