EntityName::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
/*
4
 * The MIT License
5
 *
6
 * Copyright 2016 Julien Fastré <[email protected]>.
7
 *
8
 * Permission is hereby granted, free of charge, to any person obtaining a copy
9
 * of this software and associated documentation files (the "Software"), to deal
10
 * in the Software without restriction, including without limitation the rights
11
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
 * copies of the Software, and to permit persons to whom the Software is
13
 * furnished to do so, subject to the following conditions:
14
 *
15
 * The above copyright notice and this permission notice shall be included in
16
 * all copies or substantial portions of the Software.
17
 *
18
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24
 * THE SOFTWARE.
25
 */
26
27
namespace PHPHealth\CDA\DataType\Name;
28
29
/**
30
 * A name for a person, organization, place or thing. A sequence of name parts,
31
 * such as given name or family name, prefix, suffix, etc. Examples for entity
32
 * name values are "Jim Bob Walton, Jr.", "Health Level Seven, Inc.",
33
 * "Lake Tahoe", etc. An entity name may be as simple as a character string or
34
 * may consist of several entity name parts, such as, "Jim", "Bob", "Walton",
35
 * and "Jr.", "Health Level Seven" and "Inc.", "Lake" and "Tahoe".
36
 *
37
 * Structurally, the entity name data type is a sequence of entity name part
38
 * values with an added "use" code and a valid time range for information about
39
 * if and when the name can be used for a given purpose.
40
 *
41
 * @author Julien Fastré <[email protected]>
42
 */
43
class EntityName extends \PHPHealth\CDA\DataType\AnyType
44
{
45
    /**
46
     *
47
     * @var string
48
     */
49
    protected $string;
50
    
51
    public function __construct($string = null)
52
    {
53
        $this->setString($string);
54
    }
55
    
56
    public function getString()
57
    {
58
        return $this->string;
59
    }
60
61
    public function setString($string)
62
    {
63
        $this->string = $string;
64
        return $this;
65
    }
66
        
67
    public function setValueToElement(\DOMElement &$el, \DOMDocument $doc = null)
68
    {
69
        $name = $doc->createElement('name');
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...
70
        $name->appendChild($doc->createTextNode($this->getString()));
71
        
72
        $el->appendChild($name);
73
    }
74
}
75