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