1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* The MIT License |
5
|
|
|
* |
6
|
|
|
* Copyright 2018 Peter Gee <https://github.com/pgee70>. |
7
|
|
|
* |
8
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy |
9
|
|
|
* of this software and associated documentation files (the "Software"), to deal |
10
|
|
|
* in the Software without restriction, including without limitation the rights |
11
|
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
12
|
|
|
* copies of the Software, and to permit persons to whom the Software is |
13
|
|
|
* furnished to do so, subject to the following conditions: |
14
|
|
|
* |
15
|
|
|
* The above copyright notice and this permission notice shall be included in |
16
|
|
|
* all copies or substantial portions of the Software. |
17
|
|
|
* |
18
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
19
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
20
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE |
21
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
22
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
23
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
24
|
|
|
* THE SOFTWARE. |
25
|
|
|
*/ |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* |
29
|
|
|
* @package i3Soft\CDA |
30
|
|
|
* @author Peter Gee <https://github.com/pgee70> |
31
|
|
|
* @link https://github.com/pgee70/cda |
32
|
|
|
* |
33
|
|
|
*/ |
34
|
|
|
|
35
|
|
|
|
36
|
|
|
namespace i3Soft\CDA\RIM\Entity; |
37
|
|
|
|
38
|
|
|
|
39
|
|
|
use i3Soft\CDA\Elements\AbstractElement; |
40
|
|
|
use i3Soft\CDA\Elements\Address\Addr; |
41
|
|
|
use i3Soft\CDA\Elements\Address\Telecom; |
42
|
|
|
use i3Soft\CDA\Elements\Code; |
43
|
|
|
use i3Soft\CDA\Elements\Id; |
44
|
|
|
use i3Soft\CDA\Interfaces\ClassCodeInterface; |
45
|
|
|
use i3Soft\CDA\RIM\Extensions\AsEntityIdentifier; |
46
|
|
|
use i3Soft\CDA\Traits\AddrsTrait; |
47
|
|
|
use i3Soft\CDA\Traits\AsEntityIdentifierTrait; |
48
|
|
|
use i3Soft\CDA\Traits\AssignedEntityTrait; |
49
|
|
|
use i3Soft\CDA\Traits\AssignedPersonTrait; |
50
|
|
|
use i3Soft\CDA\Traits\ClassCodeTrait; |
51
|
|
|
use i3Soft\CDA\Traits\CodeTrait; |
52
|
|
|
use i3Soft\CDA\Traits\IdTrait; |
53
|
|
|
use i3Soft\CDA\Traits\RepresentedOrganizationTrait; |
54
|
|
|
use i3Soft\CDA\Traits\TelecomsTrait; |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* Class AssignedEntity |
58
|
|
|
* |
59
|
|
|
* @package i3Soft\CDA\RIM\Role |
60
|
|
|
*/ |
61
|
|
|
class AssignedEntity extends AbstractElement implements ClassCodeInterface |
62
|
|
|
{ |
63
|
|
|
use IdTrait; |
64
|
|
|
use CodeTrait; |
65
|
|
|
use AddrsTrait; |
66
|
|
|
use TelecomsTrait; |
67
|
|
|
use AssignedEntityTrait; |
68
|
|
|
use AsEntityIdentifierTrait; |
69
|
|
|
use RepresentedOrganizationTrait; |
70
|
|
|
use AssignedPersonTrait; |
71
|
|
|
use ClassCodeTrait; |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* AssignedEntity constructor. |
75
|
|
|
* |
76
|
|
|
* @param Id $id |
77
|
|
|
* @param Code $code |
78
|
|
|
* @param Addr $addr |
79
|
|
|
* @param Telecom $telecom |
80
|
|
|
* @param AssignedPerson $assigned_person |
81
|
|
|
* @param AsEntityIdentifier $as_entity_identifier |
82
|
|
|
* @param RepresentedOrganization $represented_organization |
83
|
|
|
*/ |
84
|
|
|
public function __construct( |
85
|
|
|
Id $id, |
86
|
|
|
$code = null, |
87
|
|
|
$addr = null, |
88
|
|
|
$telecom = null, |
89
|
|
|
$assigned_person = null, |
90
|
|
|
$as_entity_identifier = null, |
91
|
|
|
$represented_organization = null |
92
|
|
|
) { |
93
|
|
|
$this->setAcceptableClassCodes(['', ClassCodeInterface::ASSIGNED]) |
94
|
|
|
->setClassCode('') |
95
|
|
|
->setId($id); |
96
|
|
|
if ($code && $code instanceof Code) { |
97
|
|
|
$this->setCode($code); |
98
|
|
|
} |
99
|
|
|
if ($addr && $addr instanceof Addr) { |
100
|
|
|
$this->addAddr($addr); |
101
|
|
|
} |
102
|
|
|
if ($telecom && $telecom instanceof Telecom) { |
103
|
|
|
$this->addTelecom($telecom); |
104
|
|
|
} |
105
|
|
|
if ($assigned_person && $assigned_person instanceof AssignedPerson) { |
106
|
|
|
$this->setAssignedPerson($assigned_person); |
107
|
|
|
} |
108
|
|
|
if ($as_entity_identifier && $as_entity_identifier instanceof AsEntityIdentifier) { |
109
|
|
|
$this->setAsEntityIdentifier($as_entity_identifier); |
110
|
|
|
} |
111
|
|
|
if ($represented_organization && $represented_organization instanceof RepresentedOrganization) { |
112
|
|
|
$this->setRepresentedOrganization($represented_organization); |
113
|
|
|
} |
114
|
|
|
} |
115
|
|
|
|
116
|
|
|
|
117
|
|
|
/** |
118
|
|
|
* @param \DOMDocument $doc |
119
|
|
|
* |
120
|
|
|
* @return \DOMElement |
121
|
|
|
*/ |
122
|
|
|
public function toDOMElement(\DOMDocument $doc): \DOMElement |
123
|
|
|
{ |
124
|
|
|
$el = $this->createElement($doc); |
125
|
|
|
$this->renderId($el, $doc); |
126
|
|
|
$this->renderCode($el, $doc); |
127
|
|
|
$this->renderAddrs($el, $doc); |
128
|
|
|
$this->renderTelecoms($el, $doc); |
129
|
|
|
$this->renderAssignedPerson($el, $doc); |
130
|
|
|
$this->renderAsEntityIdentifier($el, $doc); |
131
|
|
|
$this->renderRepresentedOrganization($el, $doc); |
132
|
|
|
return $el; |
133
|
|
|
} |
134
|
|
|
|
135
|
|
|
|
136
|
|
|
/** |
137
|
|
|
* @return string |
138
|
|
|
*/ |
139
|
|
|
protected function getElementTag(): string |
140
|
|
|
{ |
141
|
|
|
return 'assignedEntity'; |
142
|
|
|
} |
143
|
|
|
} |