Passed
Push — static-analysis ( 661417...be3dd0 )
by SignpostMarv
02:22
created

ElementRef::setNil()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
cc 2
eloc 2
c 0
b 0
f 0
nc 2
nop 1
dl 0
loc 5
ccs 0
cts 3
cp 0
crap 6
rs 9.4285
1
<?php
2
3
namespace GoetasWebservices\XML\XSDReader\Schema\Element;
4
5
use DOMElement;
6
use GoetasWebservices\XML\XSDReader\Schema\Item;
7
use GoetasWebservices\XML\XSDReader\SchemaReader;
8
9
class ElementRef extends AbstractElementSingle
10
{
11
    /**
12
     * @var ElementDef
13
     */
14
    protected $wrapped;
15
16 45
    public function __construct(ElementDef $element)
17
    {
18 45
        parent::__construct($element->getSchema(), $element->getName());
19 45
        $this->wrapped = $element;
20 45
    }
21
22
    /**
23
     * @return ElementDef
24
     */
25
    public function getReferencedElement()
26
    {
27
        return $this->wrapped;
28
    }
29
30
    /**
31
     * @return \GoetasWebservices\XML\XSDReader\Schema\Type\Type|null
32
     */
33
    public function getType()
34
    {
35
        return $this->wrapped->getType();
36
    }
37
38
    /**
39
     * @return ElementRef
40
     */
41 45
    public static function loadElementRef(
42
        ElementDef $referenced,
43
        DOMElement $node
44
    ) {
45 45
        $ref = new self($referenced);
46 45
        $ref->setDoc(SchemaReader::getDocumentation($node));
47
48 45
        SchemaReader::maybeSetMax($ref, $node);
49 45
        SchemaReader::maybeSetMin($ref, $node);
50 45
        if ($node->hasAttribute('nillable')) {
51
            $ref->setNil($node->getAttribute('nillable') == 'true');
52
        }
53 45
        if ($node->hasAttribute('form')) {
54
            $ref->setQualified($node->getAttribute('form') == 'qualified');
55
        }
56
57 45
        return $ref;
58
    }
59
}
60