Completed
Pull Request — master (#18)
by SignpostMarv
02:40
created

ElementRef::getMin()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

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