1 | <?php |
||
9 | class ResourceProperty |
||
10 | { |
||
11 | /** |
||
12 | * Property name. |
||
13 | * |
||
14 | * @var string |
||
15 | */ |
||
16 | private $_name; |
||
17 | |||
18 | /** |
||
19 | * Property MIME type. |
||
20 | * |
||
21 | * @var string |
||
22 | */ |
||
23 | private $_mimeType; |
||
24 | |||
25 | /** |
||
26 | * Property Kind, the possible values are: |
||
27 | * ResourceReference |
||
28 | * ResourceSetReference |
||
29 | * ComplexType |
||
30 | * ComplexType + Bag |
||
31 | * PrimitiveType |
||
32 | * PrimitiveType + Bag |
||
33 | * PrimitiveType + Key |
||
34 | * PrimitiveType + ETag. |
||
35 | * |
||
36 | * @var ResourcePropertyKind |
||
37 | */ |
||
38 | private $_kind; |
||
39 | |||
40 | /** |
||
41 | * ResourceType describes this property. |
||
42 | * |
||
43 | * @var ResourceType |
||
44 | */ |
||
45 | private $_propertyResourceType; |
||
46 | |||
47 | /** |
||
48 | * @param string $name Name of the property |
||
49 | * @param string $mimeType Mime type of the property |
||
50 | * @param ResourcePropertyKind $kind The kind of property |
||
51 | * @param ResourceType $propertyResourceType ResourceType of the property |
||
52 | * |
||
53 | * @throws InvalidArgumentException |
||
54 | */ |
||
55 | public function __construct($name, $mimeType, $kind, ResourceType $propertyResourceType) |
||
83 | |||
84 | /** |
||
85 | * Check whether current property is of kind specified by the parameter. |
||
86 | * |
||
87 | * @param ResourcePropertyKind $kind kind to check |
||
88 | * |
||
89 | * @return bool |
||
90 | */ |
||
91 | public function isKindOf($kind) |
||
95 | |||
96 | /** |
||
97 | * Get the property name. |
||
98 | * |
||
99 | * @return string |
||
100 | */ |
||
101 | public function getName() |
||
105 | |||
106 | /** |
||
107 | * Get property MIME type. |
||
108 | * |
||
109 | * @return string |
||
110 | */ |
||
111 | public function getMIMEType() |
||
115 | |||
116 | /** |
||
117 | * Get property kind. |
||
118 | * |
||
119 | * @return ResourcePropertyKind |
||
120 | */ |
||
121 | public function getKind() |
||
125 | |||
126 | /** |
||
127 | * Get the resource type for this property. |
||
128 | * |
||
129 | * @return ResourceType |
||
130 | */ |
||
131 | public function getResourceType() |
||
135 | |||
136 | /** |
||
137 | * Get the kind of resource type. |
||
138 | * |
||
139 | * @return ResourceTypeKind |
||
140 | */ |
||
141 | public function getTypeKind() |
||
145 | |||
146 | /** |
||
147 | * Get the instance type. If the property is of kind 'Complex', |
||
148 | * 'ResourceReference' or 'ResourceSetReference' then this function returns |
||
149 | * refernece to ReflectionClass instance for the type. If the property of |
||
150 | * kind 'Primitive' then this function returns ITYpe instance for the type. |
||
151 | * |
||
152 | * @return \ReflectionClass|IType |
||
153 | */ |
||
154 | public function getInstanceType() |
||
158 | |||
159 | /** |
||
160 | * Check once kind is of another kind. |
||
161 | * |
||
162 | * @param ResourcePropertyKind $kind1 First kind |
||
163 | * @param ResourcePropertyKind $kind2 second kind |
||
164 | * |
||
165 | * @return bool |
||
166 | */ |
||
167 | public static function sIsKindOf($kind1, $kind2) |
||
171 | |||
172 | /** |
||
173 | * Checks whether supplied name meets OData specification |
||
174 | * |
||
175 | * @param string $name Field name to be validated |
||
176 | * |
||
177 | * @return bool |
||
178 | */ |
||
179 | private function _isValidPropertyName($name) |
||
189 | |||
190 | /** |
||
191 | * Checks whether resource property kind is valid or not. |
||
192 | * |
||
193 | * @param ResourcePropertyKind $kind The kind to validate |
||
194 | * |
||
195 | * @return bool |
||
196 | */ |
||
197 | private function _isValidResourcePropertyKind($kind) |
||
209 | |||
210 | /** |
||
211 | * Check the specified resource kind is valid resource kind for property kind. |
||
212 | * |
||
213 | * @param ResourcePropertyKind $pKind The kind of resource property |
||
214 | * @param ResourceTypeKind $rKind The kind of resource type |
||
215 | * |
||
216 | * @return bool True if resource type kind and property kind matches |
||
217 | * otherwise false |
||
218 | */ |
||
219 | private function _isResourceKindValidForPropertyKind($pKind, $rKind) |
||
242 | } |
||
243 |