RepresentedCustodianOrganization::toDOMElement()   B
last analyzed

Complexity

Conditions 9
Paths 32

Size

Total Lines 36
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 15
dl 0
loc 36
rs 8.0555
c 0
b 0
f 0
cc 9
nc 32
nop 1
1
<?php
2
3
4
/**
5
 * The MIT License
6
 *
7
 * Copyright 2018  Peter Gee <https://github.com/pgee70>.
8
 *
9
 * Permission is hereby granted, free of charge, to any person obtaining a copy
10
 * of this software and associated documentation files (the "Software"), to deal
11
 * in the Software without restriction, including without limitation the rights
12
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
 * copies of the Software, and to permit persons to whom the Software is
14
 * furnished to do so, subject to the following conditions:
15
 *
16
 * The above copyright notice and this permission notice shall be included in
17
 * all copies or substantial portions of the Software.
18
 *
19
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
 * FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE
22
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25
 * THE SOFTWARE.
26
 */
27
28
namespace i3Soft\CDA\RIM\Entity;
29
30
/**
31
 * The MIT License
32
 *
33
 * Copyright 2016 julien.
34
 *
35
 * Permission is hereby granted, free of charge, to any person obtaining a copy
36
 * of this software and associated documentation files (the "Software"), to deal
37
 * in the Software without restriction, including without limitation the rights
38
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
39
 * copies of the Software, and to permit persons to whom the Software is
40
 * furnished to do so, subject to the following conditions:
41
 *
42
 * The above copyright notice and this permission notice shall be included in
43
 * all copies or substantial portions of the Software.
44
 *
45
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
46
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
47
 * FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE
48
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
49
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
50
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
51
 * THE SOFTWARE.
52
 */
53
54
use i3Soft\CDA\DataType\Collection\Set;
55
use i3Soft\CDA\Elements\Id;
56
use i3Soft\CDA\Interfaces\ClassCodeInterface;
57
58
/**
59
 * @author julien
60
 */
61
class RepresentedCustodianOrganization extends Organization
62
{
63
64
  public function __construct (Set $names, Id $id)
65
  {
66
    parent::__construct($names, $id);
67
    $this->setAcceptableClassCodes(ClassCodeInterface::EntityClassOrganization);
68
  }
69
70
71
  /**
72
   * @param \DOMDocument $doc
73
   *
74
   * @return \DOMElement
75
   */
76
  public function toDOMElement (\DOMDocument $doc): \DOMElement
77
  {
78
    $el = $this->createElement($doc);
79
80
    if ($this->hasIds())
81
    {
82
      foreach ($this->getIds() as $id)
83
      {
84
        $el->appendChild($id->toDOMElement($doc));
85
      }
86
    }
87
88
    foreach ($this->getNames()->get() as $name)
89
    {
90
      /* @var $name \i3Soft\CDA\DataType\Name\EntityName */
91
      $name->setValueToElement($el, $doc);
92
    }
93
    if ($this->hasTelecoms())
94
    {
95
      foreach ($this->getTelecoms() as $telecom)
96
      {
97
        $el->appendChild($telecom->toDOMElement($doc));
98
      }
99
    }
100
    if ($this->hasAddrs())
101
    {
102
      foreach ($this->getAddrs() as $addr)
103
      {
104
        $el->appendChild($addr->toDOMElement($doc));
105
      }
106
    }
107
    if ($this->hasAsEntityIdentifier())
108
    {
109
      $el->appendChild($this->getAsEntityIdentifier()->toDOMElement($doc));
110
    }
111
    return $el;
112
  }
113
114
115
  /**
116
   * @return string
117
   */
118
  protected function getElementTag (): string
119
  {
120
    return 'representedCustodianOrganization';
121
  }
122
}
123