Completed
Push — master ( c61dd9...791f1f )
by Thierry
01:36
created

AttrSet   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 60
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 60
rs 10
c 0
b 0
f 0
wmc 4
lcom 1
cbo 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getScript() 0 4 1
A __toString() 0 4 1
A jsonSerialize() 0 4 1
1
<?php
2
3
namespace Jaxon\Response\Plugin\Call;
4
5
use JsonSerializable;
6
7
class AttrSet implements JsonSerializable
8
{
9
    /**
10
     * The attribute name
11
     *
12
     * @var string
13
     */
14
    private $sAttrName;
15
16
    /**
17
     * The attribute value
18
     *
19
     * @var mixed
20
     */
21
    private $xAttrValue;
22
23
    /**
24
     * The constructor.
25
     *
26
     * @param string        $sAttrName            The attribute name
27
     * @param mixed         $xAttrValue           The attribute value
28
     */
29
    public function __construct($sAttrName, $xAttrValue)
30
    {
31
        $this->sAttrName = (string)$sAttrName;
32
        $this->xAttrValue = (string)$xAttrValue;
33
    }
34
35
    /**
36
     * Returns a string representation of this call
37
     *
38
     * @return string
39
     */
40
    public function getScript()
41
    {
42
        return $this->sAttrName . ' = ' . $this->xAttrValue;
43
    }
44
45
    /**
46
     * Convert this call to string
47
     *
48
     * @return string
49
     */
50
    public function __toString()
51
    {
52
        return $this->getScript();
53
    }
54
55
    /**
56
     * Convert this call to string, when converting the response into json.
57
     *
58
     * This is a method of the JsonSerializable interface.
59
     *
60
     * @return string
61
     */
62
    public function jsonSerialize()
63
    {
64
        return $this->getScript();
65
    }
66
}
67