Passed
Push — v5.x ( 6eb5e2...afe246 )
by Thierry
02:28
created

Event   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 9
dl 0
loc 35
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A jsonSerialize() 0 6 1
1
<?php
2
0 ignored issues
show
Coding Style introduced by
Missing file doc comment
Loading history...
3
namespace Jaxon\Request\Js\Selector;
4
5
use Jaxon\Request\Js\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->jsonSerialize(),
42
        ];
43
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 0 found
Loading history...
44
}
45