Completed
Push — master ( 4ef642...49bb93 )
by Julien
02:53
created

IntervalOfTime   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 6
c 0
b 0
f 0
lcom 1
cbo 2
dl 0
loc 57
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getLow() 0 4 1
A getHigh() 0 4 1
A setLow() 0 5 1
A setHigh() 0 5 1
A setValueToElement() 0 12 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 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\Collection\Interval;
26
27
use PHPHealth\CDA\ClinicalDocument as CDA;
28
use PHPHealth\CDA\DataType\Quantity\DateAndTime\TimeStamp;
29
30
31
/**
32
 * 
33
 *
34
 * @author Julien Fastré <[email protected]>
35
 */
36
class IntervalOfTime extends AbstractInterval
37
{
38
    /**
39
     *
40
     * @var TimeStamp
41
     */
42
    private $low;
43
    
44
    /**
45
     *
46
     * @var TimeStamp
47
     */
48
    private $high;
49
    
50
    function __construct(TimeStamp $low, TimeStamp $high)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
51
    {
52
        $this->setHigh($high);
53
        $this->setLow($low);
54
    }
55
56
    
57
    function getLow(): TimeStamp
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
58
    {
59
        return $this->low;
60
    }
61
62
    function getHigh(): TimeStamp
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
63
    {
64
        return $this->high;
65
    }
66
67
    function setLow(TimeStamp $low)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
68
    {
69
        $this->low = $low;
70
        return $this;
71
    }
72
73
    function setHigh(TimeStamp $high)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
74
    {
75
        $this->high = $high;
76
        return $this;
77
    }
78
79
        
80
    public function setValueToElement(\DOMElement &$el, \DOMDocument $doc = null)
81
    {
82
        $low = $doc->createElement(CDA::NS_CDA.'low');
0 ignored issues
show
Bug introduced by
It seems like $doc is not always an object, but can also be of type null. Maybe add an additional type check?

If a variable is not always an object, we recommend to add an additional type check to ensure your method call is safe:

function someFunction(A $objectMaybe = null)
{
    if ($objectMaybe instanceof A) {
        $objectMaybe->doSomething();
    }
}
Loading history...
83
        $this->low->setValueToElement($low, $doc);
84
        
85
        $high = $doc->createElement(CDA::NS_CDA.'high');
86
        $this->high->setValueToElement($high, $doc);
87
        
88
        $el->appendChild($low);
89
        $el->appendChild($high);
90
        $el->setAttribute('xsi:type', 'IVL_TS');
91
    }
92
}
93