IntervalOfTime   A
last analyzed

Complexity

Total Complexity 15

Size/Duplication

Total Lines 125
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 15
eloc 30
dl 0
loc 125
rs 10
c 0
b 0
f 0

10 Methods

Rating   Name   Duplication   Size   Complexity  
A hasLow() 0 3 1
A setValueToElement() 0 17 4
A setHigh() 0 4 1
A hasHigh() 0 3 1
A isShowXSIType() 0 3 1
A getLow() 0 3 1
A getHigh() 0 3 1
A setShowXSIType() 0 4 1
A __construct() 0 11 3
A setLow() 0 4 1
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 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\Collection\Interval;
27
28
use i3Soft\CDA\ClinicalDocument as CDA;
29
use i3Soft\CDA\DataType\Quantity\DateAndTime\TimeStamp;
30
use i3Soft\CDA\Interfaces\XSITypeInterface;
31
32
33
/**
34
 * @author Julien Fastré <[email protected]>
35
 */
36
class IntervalOfTime extends AbstractInterval
37
{
38
  /** @var TimeStamp */
39
  private $low;
40
41
  /** @var TimeStamp */
42
  private $high;
43
44
  /** @var bool */
45
  private $showXSIType;
46
47
  /**
48
   * IntervalOfTime constructor.
49
   *
50
   * @param TimeStamp $low
51
   * @param TimeStamp $high
52
   */
53
  public function __construct ($low = NULL, $high = NULL)
54
  {
55
    if ($low instanceof TimeStamp)
56
    {
57
      $this->setLow($low);
58
    }
59
    if ($high instanceof TimeStamp)
60
    {
61
      $this->setHigh($high);
62
    }
63
    $this->setShowXSIType(TRUE);
64
  }
65
66
  /**
67
   * @return TimeStamp
68
   */
69
  public function getLow (): TimeStamp
70
  {
71
    return $this->low;
72
  }
73
74
  /**
75
   * @param TimeStamp $low
76
   *
77
   * @return self
78
   */
79
  public function setLow (TimeStamp $low): self
80
  {
81
    $this->low = $low;
82
    return $this;
83
  }
84
85
  /**
86
   * @return TimeStamp
87
   */
88
  public function getHigh (): TimeStamp
89
  {
90
    return $this->high;
91
  }
92
93
  /**
94
   * @param TimeStamp $high
95
   *
96
   * @return self
97
   */
98
  public function setHigh (TimeStamp $high): self
99
  {
100
    $this->high = $high;
101
    return $this;
102
  }
103
104
  /**
105
   * @param \DOMElement       $el
106
   * @param \DOMDocument|NULL $doc
107
   */
108
  public function setValueToElement (\DOMElement $el, \DOMDocument $doc)
109
  {
110
    if ($this->hasLow())
111
    {
112
      $low = $doc->createElement(CDA::getNS() . 'low');
113
      $this->low->setValueToElement($low, $doc);
114
      $el->appendChild($low);
115
    }
116
    if ($this->hasHigh())
117
    {
118
      $high = $doc->createElement(CDA::getNS() . 'high');
119
      $this->high->setValueToElement($high, $doc);
120
      $el->appendChild($high);
121
    }
122
    if ($this->isShowXSIType())
123
    {
124
      $el->setAttribute('xsi:type', XSITypeInterface::INTERVAL_TIMESTAMP);
125
    }
126
  }
127
128
  /**
129
   * @return bool
130
   */
131
  public function hasLow (): bool
132
  {
133
    return NULL !== $this->low;
134
  }
135
136
  /**
137
   * @return bool
138
   */
139
  public function hasHigh (): bool
140
  {
141
    return NULL !== $this->high;
142
  }
143
144
  /**
145
   * @return bool
146
   */
147
  public function isShowXSIType (): bool
148
  {
149
    return $this->showXSIType;
150
  }
151
152
  /**
153
   * @param bool $showXSIType
154
   *
155
   * @return IntervalOfTime
156
   */
157
  public function setShowXSIType (bool $showXSIType): IntervalOfTime
158
  {
159
    $this->showXSIType = $showXSIType;
160
    return $this;
161
  }
162
}
163