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