Total Complexity | 6 |
Total Lines | 55 |
Duplicated Lines | 0 % |
Changes | 2 | ||
Bugs | 1 | Features | 1 |
1 | <?php |
||
17 | class Tag extends BaseObject |
||
18 | { |
||
19 | public $key; |
||
20 | public $groupKey; |
||
21 | public $value; |
||
22 | public $attributes = []; |
||
23 | |||
24 | /** |
||
25 | * @param XMLWriter $writer |
||
26 | */ |
||
27 | public function write($writer): void |
||
28 | { |
||
29 | $writer->startElement($this->key); |
||
30 | |||
31 | foreach ($this->attributes as $key => $value) { |
||
32 | $writer->writeAttribute($key, $value); |
||
33 | } |
||
34 | |||
35 | if ($this->value instanceof BaseObject) { |
||
36 | $writer->writeElement($this->groupKey, $this->value); |
||
|
|||
37 | } else { |
||
38 | $writer->text($this->value); |
||
39 | } |
||
40 | |||
41 | $writer->endElement(); |
||
42 | } |
||
43 | |||
44 | /** |
||
45 | * @param array $attributes |
||
46 | * @return Tag |
||
47 | */ |
||
48 | public function setAttributes($attributes): Tag |
||
49 | { |
||
50 | $this->attributes = $attributes; |
||
51 | return $this; |
||
52 | } |
||
53 | |||
54 | /** |
||
55 | * @param string $key |
||
56 | * @return Tag |
||
57 | */ |
||
58 | public function setKey($key): Tag |
||
59 | { |
||
60 | $this->key = $key; |
||
61 | return $this; |
||
62 | } |
||
63 | |||
64 | /** |
||
65 | * @param BaseObject|string $value |
||
66 | * @return Tag |
||
67 | */ |
||
68 | public function setValue($value): Tag |
||
72 | } |
||
73 | } |
||
74 |