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

AttrSet::__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
dl 0
loc 4
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\Request\Js\Selector;
4
5
use Jaxon\Request\Js\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
     * Returns a string representation of this call
39
     *
40
     * @return string
41
     */
42
    public function __toString(): string
43
    {
44
        return '.' . $this->sAttrName . ' = ' . $this->xAttrValue;
45
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
46
47
    /**
48
     * Convert this call to array, when converting the response into json.
49
     *
50
     * @return array
51
     */
52
    public function jsonSerialize(): array
53
    {
54
        return [
55
            '_type' => 'attr',
56
            '_name' => $this->sAttrName,
57
            'value' => $this->xAttrValue->jsonSerialize(),
58
        ];
59
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 0 found
Loading history...
60
}
61