Code Duplication    Length = 31-37 lines in 2 locations

lib/Elements/ReferenceElement.php 1 location

@@ 35-71 (lines=37) @@
32
 *
33
 * @author Julien Fastré <[email protected]>
34
 */
35
class ReferenceElement extends CharacterString
36
{
37
    /**
38
     *
39
     * @var string
40
     */
41
    private $reference;
42
    
43
    public function __construct($reference)
44
    {
45
        $this->reference = $reference;
46
    }
47
    
48
    function getReference()
49
    {
50
        return $this->reference;
51
    }
52
        
53
    protected function getElementTag()
54
    {
55
        return 'reference';
56
    }
57
58
    public function toDOMElement(\DOMDocument $doc): \DOMElement
59
    {
60
        $el = $doc->createElement(CDA::NS_CDA.'reference');
61
        
62
        $el->setAttribute(CDA::NS_CDA.'value', '#'.$this->getReference());
63
        
64
        return $el;
65
    }
66
    
67
    public function setValueToElement(\DOMElement &$el, \DOMDocument $doc = null)
68
    {
69
        $el->appendChild($this->toDOMElement($doc));
70
    }
71
}
72

lib/Elements/ReferenceType.php 1 location

@@ 34-64 (lines=31) @@
31
 *
32
 * @author Julien Fastré <[email protected]>
33
 */
34
class ReferenceType extends \PHPHealth\CDA\DataType\AnyType
35
{
36
    /**
37
     *
38
     * @var string
39
     */
40
    private $reference;
41
    
42
    public function __construct($reference)
43
    {
44
        $this->reference = $reference;
45
    }
46
    
47
    function getReference()
48
    {
49
        return $this->reference;
50
    }
51
        
52
    public function setValueToElement(\DOMElement &$el, \DOMDocument $doc = null)
53
    {
54
        $el->setAttribute('ID', $this->getReference());
55
    }
56
57
    public function toDOMElement(\DOMDocument $doc): \DOMElement
58
    {
59
        $el = $doc->createElement(CDA::NS_CDA.'reference');
60
        $el->setAttribute(CDA::NS_CDA.'value', '#'.$this->getReference());
61
        
62
        return $el;
63
    }
64
}
65