1 | <?php |
||
25 | class Attribute |
||
26 | { |
||
27 | /** @var string The name of this attribute */ |
||
28 | protected $key = ''; |
||
29 | |||
30 | /** @var string The value of this attribute */ |
||
31 | protected $value = ''; |
||
32 | |||
33 | /** |
||
34 | * Creating a new attribute. |
||
35 | * |
||
36 | * @param string $key Id for the new attribute. |
||
37 | * @param string $value Value for this attribute, |
||
38 | */ |
||
39 | 1 | public function __construct(string $key, string $value) |
|
40 | { |
||
41 | 1 | $this->key = $key; |
|
42 | 1 | $this->value = $value; |
|
43 | 1 | } |
|
44 | |||
45 | /** |
||
46 | * Sets the key for this attribute. |
||
47 | * |
||
48 | * @param string $key The new name of this attribute. |
||
49 | */ |
||
50 | 1 | public function setKey(string $key) : self |
|
51 | { |
||
52 | 1 | $this->key = $key; |
|
53 | |||
54 | 1 | return $this; |
|
55 | } |
||
56 | |||
57 | /** |
||
58 | * Returns the name for this attribute. |
||
59 | */ |
||
60 | 1 | public function getKey() : string |
|
64 | |||
65 | /** |
||
66 | * Sets the value for this attribute. |
||
67 | * |
||
68 | * @param string $value The new value. |
||
69 | */ |
||
70 | 1 | public function setValue(string $value) : self |
|
76 | |||
77 | /** |
||
78 | * Returns the value for this attribute. |
||
79 | */ |
||
80 | 1 | public function getValue() : string |
|
84 | |||
85 | /** |
||
86 | * Returns the attribute definition as is requested by GraphViz. |
||
87 | */ |
||
88 | 2 | public function __toString() : string |
|
104 | |||
105 | /** |
||
106 | * Returns whether the value contains HTML. |
||
107 | */ |
||
108 | 1 | public function isValueInHtml() : bool |
|
114 | |||
115 | /** |
||
116 | * Checks whether the value contains any any special characters needing escaping. |
||
117 | */ |
||
118 | 1 | public function isValueContainingSpecials() : bool |
|
122 | |||
123 | /** |
||
124 | * Encode special characters so the escape sequences aren't removed |
||
125 | * |
||
126 | * @see http://www.graphviz.org/doc/info/attrs.html#k:escString |
||
127 | */ |
||
128 | 1 | protected function encodeSpecials() : string |
|
135 | } |
||
136 |