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
|
|
|
/** |
31
|
|
|
* @var Extension|null |
32
|
|
|
*/ |
33
|
|
|
protected $extension; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* @param string|null $name |
37
|
|
|
*/ |
38
|
45 |
|
public function __construct(Schema $schema, $name = null) |
39
|
|
|
{ |
40
|
45 |
|
$this->name = $name ?: null; |
41
|
45 |
|
$this->schema = $schema; |
42
|
45 |
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* @return string|null |
46
|
|
|
*/ |
47
|
45 |
|
public function getName() |
48
|
|
|
{ |
49
|
45 |
|
return $this->name; |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
public function __toString() |
53
|
|
|
{ |
54
|
|
|
return strval($this->name); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* @return bool |
59
|
|
|
*/ |
60
|
|
|
public function isAbstract() |
61
|
|
|
{ |
62
|
|
|
return $this->abstract; |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* @param bool $abstract |
67
|
|
|
* |
68
|
|
|
* @return $this |
69
|
|
|
*/ |
70
|
45 |
|
public function setAbstract($abstract) |
71
|
|
|
{ |
72
|
45 |
|
$this->abstract = $abstract; |
73
|
|
|
|
74
|
45 |
|
return $this; |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* @return Restriction|Extension|null |
79
|
|
|
*/ |
80
|
|
|
public function getParent() |
81
|
|
|
{ |
82
|
|
|
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
|
45 |
|
public function setRestriction(Restriction $restriction) |
97
|
|
|
{ |
98
|
45 |
|
$this->restriction = $restriction; |
99
|
|
|
|
100
|
45 |
|
return $this; |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
/** |
104
|
|
|
* @return Extension|null |
105
|
|
|
*/ |
106
|
3 |
|
public function getExtension() |
107
|
|
|
{ |
108
|
3 |
|
return $this->extension; |
109
|
|
|
} |
110
|
|
|
|
111
|
|
|
/** |
112
|
|
|
* @return $this |
113
|
|
|
*/ |
114
|
45 |
|
public function setExtension(Extension $extension) |
115
|
|
|
{ |
116
|
45 |
|
$this->extension = $extension; |
117
|
|
|
|
118
|
45 |
|
return $this; |
119
|
|
|
} |
120
|
|
|
} |
121
|
|
|
|