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\DataType\Boolean; |
26
|
|
|
|
27
|
|
|
use PHPHealth\CDA\DataType\AnyType; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* Boolean element |
31
|
|
|
* |
32
|
|
|
* As the boolean element may be applyed with different tags, |
33
|
|
|
* the tag on wich the element apply may be set by the Element which will |
34
|
|
|
* use the data |
35
|
|
|
* |
36
|
|
|
* @author Julien Fastré <[email protected]> |
37
|
|
|
*/ |
38
|
|
|
class Boolean extends AnyType |
39
|
|
|
{ |
40
|
|
|
protected $value; |
41
|
|
|
|
42
|
|
|
protected $tag; |
43
|
|
|
|
44
|
|
|
public function __construct($value, $tag = null) |
45
|
|
|
{ |
46
|
|
|
$this->value = $value; |
47
|
|
|
$this->tag = $tag; |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
public function getValue() |
51
|
|
|
{ |
52
|
|
|
return $this->value; |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
public function getTag() |
56
|
|
|
{ |
57
|
|
|
return $this->tag; |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
public function setValue($value) |
61
|
|
|
{ |
62
|
|
|
$this->value = $value; |
63
|
|
|
return $this; |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
public function setTag($tag) |
67
|
|
|
{ |
68
|
|
|
$this->tag = $tag; |
69
|
|
|
|
70
|
|
|
return $this; |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
|
74
|
|
|
public function setValueToElement(\DOMElement &$el, \DOMDocument $doc = null) |
75
|
|
|
{ |
76
|
|
|
assert ($this->getTag() === null, new \RuntimeException("The tag " |
77
|
|
|
. "on boolean must be defined")); |
78
|
|
|
|
79
|
|
|
$el->setAttributeNS(CD::NS_CDA, $this->getTag(), $value); |
|
|
|
|
80
|
|
|
} |
81
|
|
|
} |
82
|
|
|
|
This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.