Passed
Push — v5.x ( 59ec3d...dec8cc )
by Thierry
02:06
created

Event::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 2
c 1
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\Plugin\Response\JQuery\Call;
4
5
use Jaxon\Request\Call\Call;
6
7
class Event
0 ignored issues
show
Coding Style introduced by
Missing doc comment for class Event
Loading history...
8
{
9
    /**
10
     * @var string
11
     */
12
    private $sName;
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line(s) before first member var; 0 found
Loading history...
13
14
    /**
15
     * @var Call
16
     */
17
    private $xHandler;
18
19
    /**
20
     * The constructor.
21
     *
22
     * @param string $sName    The event name
23
     * @param Call $xHandler   The event handler
0 ignored issues
show
Coding Style introduced by
Expected 3 spaces after parameter type; 1 found
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter name; 3 found
Loading history...
24
     */
25
    public function __construct(string $sName, Call $xHandler)
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines before function; 1 found
Loading history...
26
    {
27
        $this->sName = $sName;
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...
28
        $this->xHandler = $xHandler;
29
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
30
31
    /**
32
     * Convert this call to array, when converting the response into json.
33
     *
34
     * @return array
35
     */
36
    public function jsonSerialize(): array
37
    {
38
        return [
39
            '_type' => 'event',
40
            '_name' => $this->sName,
41
            'func' => $this->xHandler,
42
        ];
43
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 0 found
Loading history...
44
}
45