InstanceIdentifier::setRoot()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 5
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
/**
3
 * The MIT License
4
 *
5
 * Copyright 2016 julien.
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 NON INFRINGEMENT. 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
26
namespace i3Soft\CDA\DataType\Identifier;
27
28
use i3Soft\CDA\ClinicalDocument as CDA;
29
use i3Soft\CDA\DataType\AnyType;
30
31
/**
32
 * An identifier that uniquely identifies a thing or object. Examples are object
33
 * identifier for HL7 RIM objects, medical record number, order id, service
34
 * catalog item id, Vehicle Identification Number (VIN), etc. Instance
35
 * identifiers are defined based on ISO object identifiers.
36
 *
37
 * @author julien
38
 */
39
class InstanceIdentifier extends AnyType
40
{
41
  /**
42
   *
43
   * @var string
44
   */
45
  private $root;
46
47
  /**
48
   *
49
   * @var string
50
   */
51
  private $extension;
52
53
  /**
54
   *
55
   * @var string
56
   */
57
  private $assigningAuthorityName;
58
59
  /**
60
   * InstanceIdentifier constructor.
61
   *
62
   * @param      $root
63
   * @param null $extension
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $extension is correct as it would always require null to be passed?
Loading history...
64
   * @param null $assigningAuthorityName
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $assigningAuthorityName is correct as it would always require null to be passed?
Loading history...
65
   */
66
  public function __construct (
67
    $root,
68
    $extension = NULL,
69
    $assigningAuthorityName = NULL
70
  ) {
71
    $this->root                   = $root;
72
    $this->extension              = $extension;
73
    $this->assigningAuthorityName = $assigningAuthorityName;
74
  }
75
76
  /**
77
   * @param \DOMElement       $el
78
   * @param \DOMDocument|NULL $doc
79
   */
80
  public function setValueToElement (\DOMElement $el, \DOMDocument $doc)
81
  {
82
    $el->setAttribute(CDA::getNS() . 'root', $this->getRoot());
83
84
    if ($this->hasExtension())
85
    {
86
      $el->setAttribute(CDA::getNS() . 'extension', $this->getExtension());
87
    }
88
89
    if ($this->hasAssigningAuthorityName())
90
    {
91
      $el->setAttribute(
92
        CDA::getNS() . 'assigningAuthorityName',
93
        $this->getAssigningAuthorityName()
94
      );
95
    }
96
  }
97
98
  /**
99
   * @return string
100
   */
101
  public function getRoot (): string
102
  {
103
    return $this->root;
104
  }
105
106
  /**
107
   * @param $root
108
   *
109
   * @return self
110
   */
111
  public function setRoot ($root): self
112
  {
113
    $this->root = $root;
114
115
    return $this;
116
  }
117
118
  /**
119
   * @return bool
120
   */
121
  public function hasExtension (): bool
122
  {
123
    return $this->getExtension() !== NULL;
124
  }
125
126
  /**
127
   * @return null|string
128
   */
129
  public function getExtension ()
130
  {
131
    return $this->extension;
132
  }
133
134
  /**
135
   * @param $extension
136
   *
137
   * @return self
138
   */
139
  public function setExtension ($extension): self
140
  {
141
    $this->extension = $extension;
142
143
    return $this;
144
  }
145
146
  /**
147
   * @return bool
148
   */
149
  public function hasAssigningAuthorityName (): bool
150
  {
151
    return $this->getAssigningAuthorityName() !== NULL;
152
  }
153
154
  /**
155
   * @return null|string
156
   */
157
  public function getAssigningAuthorityName ()
158
  {
159
    return $this->assigningAuthorityName;
160
  }
161
162
  /**
163
   * @param $assigningAuthorityName
164
   *
165
   * @return self
166
   */
167
  public function setAssigningAuthorityName ($assigningAuthorityName): self
168
  {
169
    $this->assigningAuthorityName = $assigningAuthorityName;
170
171
    return $this;
172
  }
173
}
174