Passed
Push — v5.x ( 8eee51...080647 )
by Thierry
10:22
created

AttrSet::jsonSerialize()   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
c 0
b 0
f 0
dl 0
loc 6
rs 10
cc 1
nc 1
nop 0
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\Parameter;
6
7
use JsonSerializable;
8
9
class AttrSet implements JsonSerializable
0 ignored issues
show
Coding Style introduced by
Missing doc comment for class AttrSet
Loading history...
10
{
11
    /**
12
     * The attribute name
13
     *
14
     * @var string
15
     */
16
    private $sAttrName;
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line(s) before first member var; 0 found
Loading history...
17
18
    /**
19
     * The attribute value
20
     *
21
     * @var Parameter
22
     */
23
    private $xAttrValue;
24
25
    /**
26
     * The constructor.
27
     *
28
     * @param string $sAttrName    The attribute name
0 ignored issues
show
Coding Style introduced by
Expected 2 spaces after parameter name; 4 found
Loading history...
29
     * @param mixed $xAttrValue    The attribute value
0 ignored issues
show
Coding Style introduced by
Expected 2 spaces after parameter type; 1 found
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter name; 4 found
Loading history...
30
     */
31
    public function __construct(string $sAttrName, $xAttrValue)
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines before function; 1 found
Loading history...
32
    {
33
        $this->sAttrName = $sAttrName;
34
        $this->xAttrValue = Parameter::make($xAttrValue);
35
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
36
37
    /**
38
     * Convert this call to array, when converting the response into json.
39
     *
40
     * @return array
41
     */
42
    public function jsonSerialize(): array
43
    {
44
        return [
45
            '_type' => 'attr',
46
            '_name' => $this->sAttrName,
47
            'value' => $this->xAttrValue->jsonSerialize(),
48
        ];
49
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 0 found
Loading history...
50
}
51