|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace POData\ObjectModel; |
|
6
|
|
|
|
|
7
|
|
|
/** |
|
8
|
|
|
* Class ODataProperty |
|
9
|
|
|
* Represents a property that comes under "m:properties" node or entry |
|
10
|
|
|
* or under complex property. |
|
11
|
|
|
*/ |
|
12
|
|
|
class ODataProperty |
|
13
|
|
|
{ |
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* The name of the property. |
|
17
|
|
|
* |
|
18
|
|
|
* @var string |
|
19
|
|
|
*/ |
|
20
|
|
|
private $name; |
|
21
|
|
|
/** |
|
22
|
|
|
* The property type name. |
|
23
|
|
|
* |
|
24
|
|
|
* @var string|null |
|
25
|
|
|
*/ |
|
26
|
|
|
private $typeName; |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* The value of the property. |
|
30
|
|
|
* |
|
31
|
|
|
* @var mixed|ODataPropertyContent|ODataBagContent|null |
|
32
|
|
|
*/ |
|
33
|
|
|
private $value; |
|
34
|
|
|
/** |
|
35
|
|
|
* The property attribute extensions. |
|
36
|
|
|
* |
|
37
|
|
|
* @var XMLAttribute[]|null |
|
38
|
|
|
*/ |
|
39
|
|
|
public $attributeExtensions; |
|
40
|
|
|
/** |
|
41
|
|
|
* ODataProperty constructor. |
|
42
|
|
|
* @param string $name |
|
43
|
|
|
* @param string $typeName |
|
44
|
|
|
* @param XMLAttribute[] $attributeExtensions |
|
45
|
|
|
* @param ODataBagContent|ODataPropertyContent|string $value |
|
46
|
|
|
*/ |
|
47
|
|
|
public function __construct(string $name, ?string $typeName, $value, array $attributeExtensions = []) |
|
48
|
|
|
{ |
|
49
|
|
|
$this |
|
50
|
|
|
->setName($name) |
|
51
|
|
|
->setTypeName($typeName) |
|
52
|
|
|
->setValue($value) |
|
53
|
|
|
->setAttributeExtensions($attributeExtensions); |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* @return string |
|
58
|
|
|
*/ |
|
59
|
|
|
public function getName(): string |
|
60
|
|
|
{ |
|
61
|
|
|
return $this->name; |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
/** |
|
65
|
|
|
* @param string $name |
|
66
|
|
|
* @return ODataProperty |
|
67
|
|
|
*/ |
|
68
|
|
|
public function setName(string $name): ODataProperty |
|
69
|
|
|
{ |
|
70
|
|
|
$this->name = $name; |
|
71
|
|
|
return $this; |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
/** |
|
75
|
|
|
* @return string|null |
|
76
|
|
|
*/ |
|
77
|
|
|
public function getTypeName(): ?string |
|
78
|
|
|
{ |
|
79
|
|
|
return $this->typeName; |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
/** |
|
83
|
|
|
* @param string $typeName |
|
84
|
|
|
* @return ODataProperty |
|
85
|
|
|
*/ |
|
86
|
|
|
public function setTypeName(?string $typeName): ODataProperty |
|
87
|
|
|
{ |
|
88
|
|
|
$this->typeName = $typeName; |
|
89
|
|
|
return $this; |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
|
|
/** |
|
93
|
|
|
* @return XMLAttribute[]|null |
|
94
|
|
|
*/ |
|
95
|
|
|
public function getAttributeExtensions(): ?array |
|
96
|
|
|
{ |
|
97
|
|
|
return $this->attributeExtensions; |
|
98
|
|
|
} |
|
99
|
|
|
|
|
100
|
|
|
/** |
|
101
|
|
|
* @param XMLAttribute[]|null $attributeExtensions |
|
102
|
|
|
* @return ODataProperty |
|
103
|
|
|
*/ |
|
104
|
|
|
public function setAttributeExtensions(?array $attributeExtensions): ODataProperty |
|
105
|
|
|
{ |
|
106
|
|
|
$this->attributeExtensions = $attributeExtensions; |
|
107
|
|
|
return $this; |
|
108
|
|
|
} |
|
109
|
|
|
|
|
110
|
|
|
/** |
|
111
|
|
|
* @return ODataBagContent|ODataPropertyContent|string |
|
112
|
|
|
*/ |
|
113
|
|
|
public function getValue() |
|
114
|
|
|
{ |
|
115
|
|
|
return $this->value; |
|
116
|
|
|
} |
|
117
|
|
|
|
|
118
|
|
|
/** |
|
119
|
|
|
* @param ODataBagContent|ODataPropertyContent|string $value |
|
120
|
|
|
* @return ODataProperty |
|
121
|
|
|
*/ |
|
122
|
|
|
public function setValue($value) |
|
123
|
|
|
{ |
|
124
|
|
|
$this->value = $value; |
|
125
|
|
|
return $this; |
|
126
|
|
|
} |
|
127
|
|
|
|
|
128
|
|
|
/** |
|
129
|
|
|
* @return bool|null |
|
130
|
|
|
*/ |
|
131
|
|
|
public function isNull(): ?bool |
|
132
|
|
|
{ |
|
133
|
|
|
return null === $this->value ? true : null; |
|
134
|
|
|
} |
|
135
|
|
|
} |
|
136
|
|
|
|