Passed
Push — v5.x ( 6ac3c7...223ede )
by Thierry
02:17
created

AttrGet::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
0 ignored issues
show
Coding Style introduced by
Missing file doc comment
Loading history...
3
namespace Jaxon\Js\Selector;
4
5
use JsonSerializable;
6
use Stringable;
7
8
class AttrGet implements JsonSerializable, Stringable
0 ignored issues
show
Coding Style introduced by
Missing doc comment for class AttrGet
Loading history...
9
{
10
    /**
11
     * The attribute name
12
     *
13
     * @var string
14
     */
15
    private $sAttrName;
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line(s) before first member var; 0 found
Loading history...
16
17
    /**
18
     * The constructor.
19
     *
20
     * @param string $sAttrName    The attribute name
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter name; 4 found
Loading history...
21
     */
22
    public function __construct(string $sAttrName)
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines before function; 1 found
Loading history...
23
    {
24
        $this->sAttrName = $sAttrName;
25
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
26
27
    /**
28
     * Convert this call to array, when converting the response into json.
29
     *
30
     * @return array
31
     */
32
    public function jsonSerialize(): array
33
    {
34
        return [
35
            '_type' => 'attr',
36
            '_name' => $this->sAttrName,
37
        ];
38
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
39
40
    /**
41
     * Returns a string representation of the script output (javascript) from this call
42
     *
43
     * @return string
44
     */
45
    public function __toString(): string
46
    {
47
        return '.' . $this->sAttrName;
48
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 0 found
Loading history...
49
}
50