Passed
Pull Request — master (#18)
by SignpostMarv
05:20
created

Type::setName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 0
cts 3
cp 0
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 1
crap 2
1
<?php
2
3
namespace GoetasWebservices\XML\XSDReader\Schema\Type;
4
5
use GoetasWebservices\XML\XSDReader\Schema\Schema;
6
use GoetasWebservices\XML\XSDReader\Schema\SchemaItem;
7
use GoetasWebservices\XML\XSDReader\Schema\SchemaItemTrait;
8
use GoetasWebservices\XML\XSDReader\Schema\Inheritance\Extension;
9
use GoetasWebservices\XML\XSDReader\Schema\Inheritance\Restriction;
10
11
abstract class Type implements SchemaItem
12
{
13
    use SchemaItemTrait;
14
15
    /**
16
     * @var string|null
17
     */
18
    protected $name;
19
20
    /**
21
     * @var bool
22
     */
23
    protected $abstract = false;
24
25
    /**
26
     * @var Restriction|null
27
     */
28
    protected $restriction;
29
30 47
    /**
31
     * @var Extension|null
32 47
     */
33 47
    protected $extension;
34 47
35
    /**
36 47
     * @param string|null $name
37
     */
38 47
    public function __construct(Schema $schema, $name = null)
39
    {
40
        $this->name = $name ?: null;
41
        $this->schema = $schema;
42
    }
43
44
    /**
45
     * @return string|null
46
     */
47
    public function getName()
48 1
    {
49
        return $this->name;
50 1
    }
51
52
    public function __toString()
53 47
    {
54
        return strval($this->name);
55 47
    }
56
57 47
    /**
58
     * @return bool
59
     */
60
    public function isAbstract()
61
    {
62
        return $this->abstract;
63 47
    }
64
65 47
    /**
66
     * @param bool $abstract
67
     *
68
     * @return $this
69
     */
70
    public function setAbstract($abstract)
71
    {
72
        $this->abstract = $abstract;
73
74
        return $this;
75
    }
76
77
    /**
78 47
     * @return Restriction|Extension|null
79
     */
80 47
    public function getParent()
81
    {
82 47
        return $this->restriction ?: $this->extension;
83
    }
84
85
    /**
86
     * @return Restriction|null
87
     */
88
    public function getRestriction()
89
    {
90
        return $this->restriction;
91
    }
92
93
    /**
94
     * @return $this
95
     */
96
    public function setRestriction(Restriction $restriction)
97
    {
98 47
        $this->restriction = $restriction;
99
100 47
        return $this;
101
    }
102 47
103
    /**
104
     * @return Extension|null
105 3
     */
106
    public function getExtension()
107 3
    {
108
        return $this->extension;
109
    }
110 47
111
    /**
112 47
     * @return $this
113
     */
114 47
    public function setExtension(Extension $extension)
115
    {
116
        $this->extension = $extension;
117
118
        return $this;
119
    }
120
}
121