1
|
|
|
<?php |
2
|
|
|
/* |
3
|
|
|
* The MIT License |
4
|
|
|
* |
5
|
|
|
* Copyright 2017 Julien Fastré <[email protected]>. |
6
|
|
|
* |
7
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy |
8
|
|
|
* of this software and associated documentation files (the "Software"), to deal |
9
|
|
|
* in the Software without restriction, including without limitation the rights |
10
|
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
11
|
|
|
* copies of the Software, and to permit persons to whom the Software is |
12
|
|
|
* furnished to do so, subject to the following conditions: |
13
|
|
|
* |
14
|
|
|
* The above copyright notice and this permission notice shall be included in |
15
|
|
|
* all copies or substantial portions of the Software. |
16
|
|
|
* |
17
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
18
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
19
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
20
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
21
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
22
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
23
|
|
|
* THE SOFTWARE. |
24
|
|
|
*/ |
25
|
|
|
namespace PHPHealth\CDA\Elements; |
26
|
|
|
|
27
|
|
|
use PHPHealth\CDA\Elements\AbstractElement; |
28
|
|
|
use PHPHealth\CDA\Elements\TableRow; |
29
|
|
|
use PHPHealth\CDA\Elements\ReferenceType; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* |
33
|
|
|
* |
34
|
|
|
* @author Julien Fastré <[email protected]> |
35
|
|
|
*/ |
36
|
|
|
class TableCell extends AbstractElement |
37
|
|
|
{ |
38
|
|
|
/** |
39
|
|
|
* |
40
|
|
|
* @var string |
41
|
|
|
*/ |
42
|
|
|
private $content; |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* |
46
|
|
|
* @var ReferenceType |
47
|
|
|
*/ |
48
|
|
|
private $reference; |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* |
52
|
|
|
* @var TableRow |
53
|
|
|
*/ |
54
|
|
|
private $row; |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* a string determining if the row is th or td |
58
|
|
|
* |
59
|
|
|
* @var string |
60
|
|
|
*/ |
61
|
|
|
private $level; |
62
|
|
|
|
63
|
|
|
const TH = 'th'; |
64
|
|
|
const TD = 'td'; |
65
|
|
|
|
66
|
|
|
|
67
|
|
|
function __construct($level, TableRow $row = null, $content = '') |
|
|
|
|
68
|
|
|
{ |
69
|
|
|
$this->setContent($content); |
70
|
|
|
$this->level = $level; |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* |
75
|
|
|
* @return string |
76
|
|
|
*/ |
77
|
|
|
function getContent() |
|
|
|
|
78
|
|
|
{ |
79
|
|
|
return $this->content; |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* |
84
|
|
|
* @param string $content |
85
|
|
|
* @return $this |
86
|
|
|
*/ |
87
|
|
|
function setContent($content) |
|
|
|
|
88
|
|
|
{ |
89
|
|
|
$this->content = $content; |
90
|
|
|
|
91
|
|
|
return $this; |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* |
96
|
|
|
* @return TableRow |
97
|
|
|
*/ |
98
|
|
|
function getRow(): TableRow |
|
|
|
|
99
|
|
|
{ |
100
|
|
|
return $this->row; |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
/** |
104
|
|
|
* |
105
|
|
|
* @param TableRow $row |
106
|
|
|
* @return $this |
107
|
|
|
*/ |
108
|
|
|
function setRow(TableRow $row) |
|
|
|
|
109
|
|
|
{ |
110
|
|
|
$this->row = $row; |
111
|
|
|
|
112
|
|
|
return $this; |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
/** |
116
|
|
|
* |
117
|
|
|
* @return ReferenceType |
118
|
|
|
*/ |
119
|
|
|
function getReference() |
|
|
|
|
120
|
|
|
{ |
121
|
|
|
return $this->reference; |
122
|
|
|
} |
123
|
|
|
|
124
|
|
|
/** |
125
|
|
|
* |
126
|
|
|
* @param ReferenceType $reference |
127
|
|
|
* @return $this |
128
|
|
|
*/ |
129
|
|
|
function setReference(ReferenceType $reference) |
|
|
|
|
130
|
|
|
{ |
131
|
|
|
$this->reference = $reference; |
132
|
|
|
|
133
|
|
|
return $this; |
134
|
|
|
} |
135
|
|
|
|
136
|
|
|
|
137
|
|
|
/** |
138
|
|
|
* |
139
|
|
|
* @return boolean |
140
|
|
|
*/ |
141
|
|
|
public function isEmpty() |
142
|
|
|
{ |
143
|
|
|
return empty($this->getContent()); |
144
|
|
|
} |
145
|
|
|
|
146
|
|
|
protected function getElementTag(): string |
147
|
|
|
{ |
148
|
|
|
return $this->level; |
149
|
|
|
} |
150
|
|
|
|
151
|
|
View Code Duplication |
public function toDOMElement(\DOMDocument $doc): \DOMElement |
|
|
|
|
152
|
|
|
{ |
153
|
|
|
$el = $this->createElement($doc); |
154
|
|
|
|
155
|
|
|
if ($this->getReference() !== null) { |
156
|
|
|
$this->getReference()->setValueToElement($el, $doc); |
157
|
|
|
} |
158
|
|
|
|
159
|
|
|
$el->appendChild($doc->createTextNode($this->getContent())); |
160
|
|
|
|
161
|
|
|
return $el; |
162
|
|
|
} |
163
|
|
|
} |
164
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.