| Total Complexity | 43 |
| Total Lines | 509 |
| Duplicated Lines | 0 % |
| Changes | 2 | ||
| Bugs | 1 | Features | 0 |
Complex classes like EdmCoreModel often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use EdmCoreModel, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 47 | class EdmCoreModel extends EdmElement implements IModel, IEdmValidCoreModelElement |
||
| 48 | { |
||
| 49 | use ModelHelpers; |
||
|
|
|||
| 50 | |||
| 51 | private static $instance = null; |
||
| 52 | |||
| 53 | public static function getInstance(): EdmCoreModel |
||
| 56 | } |
||
| 57 | |||
| 58 | /** |
||
| 59 | * @var EdmValidCoreModelPrimitiveType[] |
||
| 60 | */ |
||
| 61 | private $primitiveTypes; |
||
| 62 | |||
| 63 | private const EdmNamespace = 'Edm'; |
||
| 64 | /** |
||
| 65 | * @var array<string, PrimitiveTypeKind> |
||
| 66 | */ |
||
| 67 | private $primitiveTypeKinds = []; |
||
| 68 | /** |
||
| 69 | * @var array<PrimitiveTypeKind, EdmValidCoreModelPrimitiveType> |
||
| 70 | */ |
||
| 71 | private $primitiveTypesByKind = []; |
||
| 72 | /** |
||
| 73 | * @var array<string, EdmValidCoreModelPrimitiveType> |
||
| 74 | */ |
||
| 75 | private $primitiveTypeByName = []; |
||
| 76 | /** |
||
| 77 | * @var EdmDirectValueAnnotationsManager |
||
| 78 | */ |
||
| 79 | private $annotationsManager; |
||
| 80 | |||
| 81 | public function __construct() |
||
| 82 | { |
||
| 83 | $this->annotationsManager = new EdmDirectValueAnnotationsManager(); |
||
| 84 | $primitiveDouble = new EdmValidCoreModelPrimitiveType(self::EdmNamespace, 'Double', PrimitiveTypeKind::Double()); |
||
| 85 | $primitiveSingle = new EdmValidCoreModelPrimitiveType(self::EdmNamespace, 'Single', PrimitiveTypeKind::Single()); |
||
| 86 | |||
| 87 | $primitiveInt64 = new EdmValidCoreModelPrimitiveType(self::EdmNamespace, 'Int64', PrimitiveTypeKind::Int64()); |
||
| 88 | $primitiveInt32 = new EdmValidCoreModelPrimitiveType(self::EdmNamespace, 'Int32', PrimitiveTypeKind::Int32()); |
||
| 89 | $primitiveInt16 = new EdmValidCoreModelPrimitiveType(self::EdmNamespace, 'Int16', PrimitiveTypeKind::Int16()); |
||
| 90 | $primitiveSByte = new EdmValidCoreModelPrimitiveType(self::EdmNamespace, 'SByte', PrimitiveTypeKind::SByte()); |
||
| 91 | $primitiveByte = new EdmValidCoreModelPrimitiveType(self::EdmNamespace, 'Byte', PrimitiveTypeKind::Byte()); |
||
| 92 | |||
| 93 | $primitiveBoolean = new EdmValidCoreModelPrimitiveType(self::EdmNamespace, 'Boolean', PrimitiveTypeKind::Boolean()); |
||
| 94 | $primitiveGuid = new EdmValidCoreModelPrimitiveType(self::EdmNamespace, 'Guid', PrimitiveTypeKind::Guid()); |
||
| 95 | |||
| 96 | $primitiveTime = new EdmValidCoreModelPrimitiveType(self::EdmNamespace, 'Time', PrimitiveTypeKind::Time()); |
||
| 97 | $primitiveDateTime = new EdmValidCoreModelPrimitiveType(self::EdmNamespace, 'DateTime', PrimitiveTypeKind::DateTime()); |
||
| 98 | $primitiveDateTimeOffset = new EdmValidCoreModelPrimitiveType(self::EdmNamespace, 'DateTimeOffset', PrimitiveTypeKind::DateTimeOffset()); |
||
| 99 | |||
| 100 | $primitiveDecimal = new EdmValidCoreModelPrimitiveType(self::EdmNamespace, 'Decimal', PrimitiveTypeKind::Decimal()); |
||
| 101 | |||
| 102 | $primitiveBinary = new EdmValidCoreModelPrimitiveType(self::EdmNamespace, 'Binary', PrimitiveTypeKind::Binary()); |
||
| 103 | $primitiveString = new EdmValidCoreModelPrimitiveType(self::EdmNamespace, 'String', PrimitiveTypeKind::String()); |
||
| 104 | $primitiveStream = new EdmValidCoreModelPrimitiveType(self::EdmNamespace, 'Stream', PrimitiveTypeKind::Stream()); |
||
| 105 | |||
| 106 | $primitiveGeography = new EdmValidCoreModelPrimitiveType(self::EdmNamespace, 'Geography', PrimitiveTypeKind::Geography()); |
||
| 107 | $primitiveGeographyPoint = new EdmValidCoreModelPrimitiveType(self::EdmNamespace, 'GeographyPoint', PrimitiveTypeKind::GeographyPoint()); |
||
| 108 | $primitiveGeographyLineString = new EdmValidCoreModelPrimitiveType(self::EdmNamespace, 'GeographyLineString', PrimitiveTypeKind::GeographyLineString()); |
||
| 109 | $primitiveGeographyPolygon = new EdmValidCoreModelPrimitiveType(self::EdmNamespace, 'GeographyPolygon', PrimitiveTypeKind::GeographyPolygon()); |
||
| 110 | $primitiveGeographyCollection = new EdmValidCoreModelPrimitiveType(self::EdmNamespace, 'GeographyCollection', PrimitiveTypeKind::GeographyCollection()); |
||
| 111 | $primitiveGeographyMultiPolygon = new EdmValidCoreModelPrimitiveType(self::EdmNamespace, 'GeographyMultiPolygon', PrimitiveTypeKind::GeographyMultiPolygon()); |
||
| 112 | $primitiveGeographyMultiLineString = new EdmValidCoreModelPrimitiveType(self::EdmNamespace, 'GeographyMultiLineString', PrimitiveTypeKind::GeographyMultiLineString()); |
||
| 113 | $primitiveGeographyMultiPoint = new EdmValidCoreModelPrimitiveType(self::EdmNamespace, 'GeographyMultiPoint', PrimitiveTypeKind::GeographyMultiPoint()); |
||
| 114 | $primitiveGeometry = new EdmValidCoreModelPrimitiveType(self::EdmNamespace, 'Geometry', PrimitiveTypeKind::Geometry()); |
||
| 115 | $primitiveGeometryPoint = new EdmValidCoreModelPrimitiveType(self::EdmNamespace, 'GeometryPoint', PrimitiveTypeKind::GeometryPoint()); |
||
| 116 | $primitiveGeometryLineString = new EdmValidCoreModelPrimitiveType(self::EdmNamespace, 'GeometryLineString', PrimitiveTypeKind::GeometryLineString()); |
||
| 117 | $primitiveGeometryPolygon = new EdmValidCoreModelPrimitiveType(self::EdmNamespace, 'GeometryPolygon', PrimitiveTypeKind::GeometryPolygon()); |
||
| 118 | $primitiveGeometryCollection = new EdmValidCoreModelPrimitiveType(self::EdmNamespace, 'GeometryCollection', PrimitiveTypeKind::GeometryCollection()); |
||
| 119 | $primitiveGeometryMultiPolygon = new EdmValidCoreModelPrimitiveType(self::EdmNamespace, 'GeometryMultiPolygon', PrimitiveTypeKind::GeometryMultiPolygon()); |
||
| 120 | $primitiveGeometryMultiLineString = new EdmValidCoreModelPrimitiveType(self::EdmNamespace, 'GeometryMultiLineString', PrimitiveTypeKind::GeometryMultiLineString()); |
||
| 121 | $primitiveGeometryMultiPoint = new EdmValidCoreModelPrimitiveType(self::EdmNamespace, 'GeometryMultiPoint', PrimitiveTypeKind::GeometryMultiPoint()); |
||
| 122 | $this->primitiveTypes = [ |
||
| 123 | $primitiveBinary, |
||
| 124 | $primitiveBoolean, |
||
| 125 | $primitiveByte, |
||
| 126 | $primitiveDateTime, |
||
| 127 | $primitiveDateTimeOffset, |
||
| 128 | $primitiveDecimal, |
||
| 129 | $primitiveDouble, |
||
| 130 | $primitiveGuid, |
||
| 131 | $primitiveInt16, |
||
| 132 | $primitiveInt32, |
||
| 133 | $primitiveInt64, |
||
| 134 | $primitiveSByte, |
||
| 135 | $primitiveSingle, |
||
| 136 | $primitiveStream, |
||
| 137 | $primitiveString, |
||
| 138 | $primitiveTime, |
||
| 139 | $primitiveGeography, |
||
| 140 | $primitiveGeographyPoint, |
||
| 141 | $primitiveGeographyLineString, |
||
| 142 | $primitiveGeographyPolygon, |
||
| 143 | $primitiveGeographyCollection, |
||
| 144 | $primitiveGeographyMultiPolygon, |
||
| 145 | $primitiveGeographyMultiLineString, |
||
| 146 | $primitiveGeographyMultiPoint, |
||
| 147 | $primitiveGeometry, |
||
| 148 | $primitiveGeometryPoint, |
||
| 149 | $primitiveGeometryLineString, |
||
| 150 | $primitiveGeometryPolygon, |
||
| 151 | $primitiveGeometryCollection, |
||
| 152 | $primitiveGeometryMultiPolygon, |
||
| 153 | $primitiveGeometryMultiLineString, |
||
| 154 | $primitiveGeometryMultiPoint |
||
| 155 | ]; |
||
| 156 | /** @var EdmValidCoreModelPrimitiveType $primitive */ |
||
| 157 | foreach ($this->primitiveTypes as $primitive) { |
||
| 158 | EdmUtil::checkArgumentNull($primitive->getNamespace(), 'primitive->getNamespace'); |
||
| 159 | $this->primitiveTypeKinds[$primitive->getName()] = $primitive->getPrimitiveKind(); |
||
| 160 | $this->primitiveTypeKinds[$primitive->getNamespace() . '.' . $primitive->getName()] = $primitive->getPrimitiveKind(); |
||
| 161 | $this->primitiveTypesByKind[$primitive->getPrimitiveKind()->getValue()] = $primitive; |
||
| 162 | $this->primitiveTypeByName[$primitive->getNamespace() . '.' . $primitive->getName()] = $primitive; |
||
| 163 | } |
||
| 164 | } |
||
| 165 | |||
| 166 | /** |
||
| 167 | * @return string gets the namespace of this core model |
||
| 168 | */ |
||
| 169 | public static function namespace(): string |
||
| 170 | { |
||
| 171 | return 'Edm'; |
||
| 172 | } |
||
| 173 | |||
| 174 | /** |
||
| 175 | * Gets the collection of schema elements that are contained in this model. |
||
| 176 | * |
||
| 177 | * @return ISchemaElement[] |
||
| 178 | */ |
||
| 179 | public function getSchemaElements(): array |
||
| 180 | { |
||
| 181 | return $this->primitiveTypes; |
||
| 182 | } |
||
| 183 | |||
| 184 | /** |
||
| 185 | * Gets the collection of vocabulary annotations that are contained in this model. |
||
| 186 | * |
||
| 187 | * @return Annotations\IVocabularyAnnotation[] |
||
| 188 | */ |
||
| 189 | public function getVocabularyAnnotations(): array |
||
| 190 | { |
||
| 191 | return []; |
||
| 192 | } |
||
| 193 | |||
| 194 | /** |
||
| 195 | * Gets the collection of models referred to by this model. |
||
| 196 | * |
||
| 197 | * @return IModel[] |
||
| 198 | */ |
||
| 199 | public function getReferencedModels(): array |
||
| 202 | } |
||
| 203 | |||
| 204 | /** |
||
| 205 | * Gets the model's annotations manager. |
||
| 206 | * |
||
| 207 | * @return Annotations\IDirectValueAnnotationsManager |
||
| 208 | */ |
||
| 209 | public function getDirectValueAnnotationsManager(): Annotations\IDirectValueAnnotationsManager |
||
| 210 | { |
||
| 211 | return $this->annotationsManager; |
||
| 212 | } |
||
| 213 | |||
| 214 | /** |
||
| 215 | * Searches for an entity container with the given name in this model and returns null if no such entity container |
||
| 216 | * exists. |
||
| 217 | * |
||
| 218 | * @param string $qualifiedName the name of the entity container being found |
||
| 219 | * @return ISchemaType|null The requested entity container, or null if no such entity container exists |
||
| 220 | */ |
||
| 221 | public function findDeclaredType(string $qualifiedName): ?ISchemaType |
||
| 222 | { |
||
| 223 | return array_key_exists($qualifiedName, $this->primitiveTypeByName) ? $this->primitiveTypeByName[$qualifiedName] : null; |
||
| 224 | } |
||
| 225 | |||
| 226 | /** |
||
| 227 | * Searches for a type with the given name in this model and returns null if no such type exists. |
||
| 228 | * |
||
| 229 | * @param string $name the qualified name of the type being found |
||
| 230 | * @return IEntityContainer|null the requested type, or null if no such type exists |
||
| 231 | */ |
||
| 232 | public function findDeclaredEntityContainer(string $name): ?IEntityContainer |
||
| 233 | { |
||
| 234 | return null; |
||
| 235 | } |
||
| 236 | |||
| 237 | /** |
||
| 238 | * Searches for functions with the given name in this model and returns an empty enumerable if no such function |
||
| 239 | * exists. |
||
| 240 | * |
||
| 241 | * @param string $qualifiedName the qualified name of the function being found |
||
| 242 | * @return IFunction[] a set of functions sharing the specified qualified name, or an empty enumerable if no |
||
| 243 | * such function exists |
||
| 244 | */ |
||
| 245 | public function findDeclaredFunctions(string $qualifiedName): array |
||
| 246 | { |
||
| 247 | return []; |
||
| 248 | } |
||
| 249 | |||
| 250 | /** |
||
| 251 | * Searches for a value term with the given name in this model and returns null if no such value term exists. |
||
| 252 | * |
||
| 253 | * @param string $qualifiedName the qualified name of the value term being found |
||
| 254 | * @return IValueTerm|null the requested value term, or null if no such value term exists |
||
| 255 | */ |
||
| 256 | public function findDeclaredValueTerm(string $qualifiedName): ?IValueTerm |
||
| 257 | { |
||
| 258 | return null; |
||
| 259 | } |
||
| 260 | |||
| 261 | /** |
||
| 262 | * Searches for vocabulary annotations specified by this model. |
||
| 263 | * |
||
| 264 | * @param IVocabularyAnnotatable $element the annotated element |
||
| 265 | * @return Annotations\IVocabularyAnnotation[] the vocabulary annotations for the element |
||
| 266 | */ |
||
| 267 | public function findDeclaredVocabularyAnnotations(IVocabularyAnnotatable $element): array |
||
| 268 | { |
||
| 269 | return []; |
||
| 270 | } |
||
| 271 | |||
| 272 | /** |
||
| 273 | * Finds a list of types that derive directly from the supplied type. |
||
| 274 | * |
||
| 275 | * @param IStructuredType $baseType the base type that derived types are being searched for |
||
| 276 | * @return IStructuredType[] a list of types from this model that derive directly from the given type |
||
| 277 | */ |
||
| 278 | public function findDirectlyDerivedTypes(IStructuredType $baseType): array |
||
| 279 | { |
||
| 280 | return []; |
||
| 281 | } |
||
| 282 | |||
| 283 | /** |
||
| 284 | * Gets a reference to a non-atomic collection type definition. |
||
| 285 | * |
||
| 286 | * @param ITypeReference $elementType type of elements in the collection |
||
| 287 | * @return ICollectionTypeReference a new non-atomic collection type reference |
||
| 288 | */ |
||
| 289 | public static function getCollection(ITypeReference $elementType): ICollectionTypeReference |
||
| 290 | { |
||
| 291 | return new EdmCollectionTypeReference(new EdmCollectionType($elementType), false); |
||
| 292 | } |
||
| 293 | |||
| 294 | private function getCoreModelPrimitiveType(PrimitiveTypeKind $kind): ?EdmValidCoreModelPrimitiveType |
||
| 295 | { |
||
| 296 | return array_key_exists(strval($kind), $this->primitiveTypesByKind) ? |
||
| 297 | $this->primitiveTypesByKind[strval($kind)] : null; |
||
| 298 | } |
||
| 299 | |||
| 300 | /** |
||
| 301 | * Gets primitive type by kind. |
||
| 302 | * |
||
| 303 | * @param PrimitiveTypeKind $kind kind of the primitive type |
||
| 304 | * @return IPrimitiveType|null primitive type definition |
||
| 305 | */ |
||
| 306 | public function getPrimitiveType(PrimitiveTypeKind $kind): ?IPrimitiveType |
||
| 307 | { |
||
| 308 | return $this->getCoreModelPrimitiveType($kind); |
||
| 309 | } |
||
| 310 | |||
| 311 | /** |
||
| 312 | * Gets the PrimitiveTypeKind by the type name. |
||
| 313 | * |
||
| 314 | * @param string $typeName name of the type to look up |
||
| 315 | * @return PrimitiveTypeKind PrimitiveTypeKind of the type.< |
||
| 316 | */ |
||
| 317 | public function getPrimitiveTypeKind(string $typeName): PrimitiveTypeKind |
||
| 318 | { |
||
| 319 | return array_key_exists($typeName, $this->primitiveTypeKinds) ? $this->primitiveTypeKinds[$typeName] : PrimitiveTypeKind::None(); |
||
| 320 | } |
||
| 321 | |||
| 322 | /** |
||
| 323 | * Gets a reference to a primitive type of the specified kind. |
||
| 324 | * |
||
| 325 | * @param PrimitiveTypeKind $kind primitive kind of the type reference being created |
||
| 326 | * @param bool $isNullable flag specifying if the referenced type should be nullable |
||
| 327 | * @return IPrimitiveTypeReference a new primitive type reference |
||
| 328 | */ |
||
| 329 | public function getPrimitive(PrimitiveTypeKind $kind, bool $isNullable): IPrimitiveTypeReference |
||
| 330 | { |
||
| 331 | $primitiveDefinition = $this->getCoreModelPrimitiveType($kind); |
||
| 332 | if ($primitiveDefinition !== null) { |
||
| 333 | return $primitiveDefinition->getPrimitiveTypeReference($isNullable); |
||
| 334 | } else { |
||
| 335 | throw new InvalidOperationException(StringConst::EdmPrimitive_UnexpectedKind()); |
||
| 336 | } |
||
| 337 | } |
||
| 338 | |||
| 339 | /** |
||
| 340 | * Gets a reference to the Int16 primitive type definition. |
||
| 341 | * |
||
| 342 | * @param bool $isNullable flag specifying if the referenced type should be nullable |
||
| 343 | * @return IPrimitiveTypeReference a new primitive type reference |
||
| 344 | */ |
||
| 345 | public function getInt16(bool $isNullable): IPrimitiveTypeReference |
||
| 346 | { |
||
| 347 | return new EdmPrimitiveTypeReference($this->getCoreModelPrimitiveType(PrimitiveTypeKind::Int16()), $isNullable); |
||
| 348 | } |
||
| 349 | |||
| 350 | /** |
||
| 351 | * Gets a reference to the Int32 primitive type definition. |
||
| 352 | * |
||
| 353 | * @param bool $isNullable flag specifying if the referenced type should be nullable |
||
| 354 | * @return IPrimitiveTypeReference a new primitive type reference |
||
| 355 | */ |
||
| 356 | public function getInt32(bool $isNullable): IPrimitiveTypeReference |
||
| 357 | { |
||
| 358 | return new EdmPrimitiveTypeReference($this->getCoreModelPrimitiveType(PrimitiveTypeKind::Int32()), $isNullable); |
||
| 359 | } |
||
| 360 | |||
| 361 | /** |
||
| 362 | * Gets a reference to the Int64 primitive type definition. |
||
| 363 | * |
||
| 364 | * @param bool $isNullable flag specifying if the referenced type should be nullable |
||
| 365 | * @return IPrimitiveTypeReference a new primitive type reference |
||
| 366 | */ |
||
| 367 | public function getInt64(bool $isNullable): IPrimitiveTypeReference |
||
| 368 | { |
||
| 369 | return new EdmPrimitiveTypeReference($this->getCoreModelPrimitiveType(PrimitiveTypeKind::Int64()), $isNullable); |
||
| 370 | } |
||
| 371 | |||
| 372 | /** |
||
| 373 | * Gets a reference to the Boolean primitive type definition. |
||
| 374 | * |
||
| 375 | * @param bool $isNullable flag specifying if the referenced type should be nullable |
||
| 376 | * @return IPrimitiveTypeReference a new primitive type reference |
||
| 377 | */ |
||
| 378 | public function getBoolean(bool $isNullable): IPrimitiveTypeReference |
||
| 379 | { |
||
| 380 | return new EdmPrimitiveTypeReference($this->getCoreModelPrimitiveType(PrimitiveTypeKind::Boolean()), $isNullable); |
||
| 381 | } |
||
| 382 | |||
| 383 | /** |
||
| 384 | * Gets a reference to the Byte primitive type definition. |
||
| 385 | * |
||
| 386 | * @param bool $isNullable flag specifying if the referenced type should be nullable |
||
| 387 | * @return IPrimitiveTypeReference A new primitive type reference.< |
||
| 388 | */ |
||
| 389 | public function getByte(bool $isNullable): IPrimitiveTypeReference |
||
| 390 | { |
||
| 391 | return new EdmPrimitiveTypeReference($this->getCoreModelPrimitiveType(PrimitiveTypeKind::Byte()), $isNullable); |
||
| 392 | } |
||
| 393 | |||
| 394 | /** |
||
| 395 | * Gets a reference to the SByte primitive type definition. |
||
| 396 | * |
||
| 397 | * @param bool $isNullable flag specifying if the referenced type should be nullable |
||
| 398 | * @return IPrimitiveTypeReference a new primitive type reference |
||
| 399 | */ |
||
| 400 | public function getSByte(bool $isNullable): IPrimitiveTypeReference |
||
| 401 | { |
||
| 402 | return new EdmPrimitiveTypeReference($this->getCoreModelPrimitiveType(PrimitiveTypeKind::SByte()), $isNullable); |
||
| 403 | } |
||
| 404 | |||
| 405 | /** |
||
| 406 | * Gets a reference to the Guid primitive type definition. |
||
| 407 | * |
||
| 408 | * @param bool $isNullable flag specifying if the referenced type should be nullable |
||
| 409 | * @return IPrimitiveTypeReference a new primitive type reference |
||
| 410 | */ |
||
| 411 | public function getGuid(bool $isNullable): IPrimitiveTypeReference |
||
| 412 | { |
||
| 413 | return new EdmPrimitiveTypeReference($this->getCoreModelPrimitiveType(PrimitiveTypeKind::Guid()), $isNullable); |
||
| 414 | } |
||
| 415 | |||
| 416 | /** |
||
| 417 | * Gets a reference to a datetime primitive type definition. |
||
| 418 | * |
||
| 419 | * @param bool $isNullable flag specifying if the referenced type should be nullable |
||
| 420 | * @return ITemporalTypeReference a new datetime type reference |
||
| 421 | */ |
||
| 422 | public function getDateTime(bool $isNullable): ITemporalTypeReference |
||
| 423 | { |
||
| 424 | return new EdmTemporalTypeReference($this->getCoreModelPrimitiveType(PrimitiveTypeKind::DateTime()), $isNullable); |
||
| 425 | } |
||
| 426 | |||
| 427 | /** |
||
| 428 | * Gets a reference to a datetime with offset primitive type definition. |
||
| 429 | * |
||
| 430 | * @param bool $isNullable flag specifying if the referenced type should be nullable |
||
| 431 | * @return ITemporalTypeReference a new datetime with offset type reference |
||
| 432 | */ |
||
| 433 | public function getDateTimeOffset(bool $isNullable): ITemporalTypeReference |
||
| 434 | { |
||
| 435 | return new EdmTemporalTypeReference($this->getCoreModelPrimitiveType(PrimitiveTypeKind::DateTimeOffset()), $isNullable); |
||
| 436 | } |
||
| 437 | |||
| 438 | /** |
||
| 439 | * Gets a reference to a time primitive type definition. |
||
| 440 | * |
||
| 441 | * @param bool $isNullable flag specifying if the referenced type should be nullable |
||
| 442 | * @return ITemporalTypeReference a new time type reference |
||
| 443 | */ |
||
| 444 | public function getTime(bool $isNullable): ITemporalTypeReference |
||
| 445 | { |
||
| 446 | return new EdmTemporalTypeReference($this->getCoreModelPrimitiveType(PrimitiveTypeKind::Time()), $isNullable); |
||
| 447 | } |
||
| 448 | |||
| 449 | /** |
||
| 450 | * Gets a reference to a decimal primitive type definition. |
||
| 451 | * |
||
| 452 | * @param int|null $precision precision of values of this type |
||
| 453 | * @param int|null $scale scale of values of this type |
||
| 454 | * @param bool $isNullable flag specifying if the referenced type should be nullable |
||
| 455 | * @return IDecimalTypeReference a new decimal type reference |
||
| 456 | */ |
||
| 457 | public function getDecimal(?int $precision, ?int $scale, bool $isNullable): IDecimalTypeReference |
||
| 458 | { |
||
| 459 | // Facet values may render this reference as semantically invalid, so can't return an IEdmValidCoreModelElement. |
||
| 460 | return new EdmDecimalTypeReference($this->getCoreModelPrimitiveType(PrimitiveTypeKind::Decimal()), $isNullable, $precision, $scale); |
||
| 461 | } |
||
| 462 | |||
| 463 | /** |
||
| 464 | * Gets a reference to a single primitive type definition. |
||
| 465 | * |
||
| 466 | * @param bool $isNullable flag specifying if the referenced type should be nullable |
||
| 467 | * @return IPrimitiveTypeReference a new single type reference |
||
| 468 | */ |
||
| 469 | public function getSingle(bool $isNullable): IPrimitiveTypeReference |
||
| 470 | { |
||
| 471 | return new EdmPrimitiveTypeReference($this->getCoreModelPrimitiveType(PrimitiveTypeKind::Single()), $isNullable); |
||
| 472 | } |
||
| 473 | |||
| 474 | /** |
||
| 475 | * Gets a reference to a double primitive type definition. |
||
| 476 | * |
||
| 477 | * @param bool $isNullable flag specifying if the referenced type should be nullable |
||
| 478 | * @return IPrimitiveTypeReference a new double type reference |
||
| 479 | */ |
||
| 480 | public function getDouble(bool $isNullable): IPrimitiveTypeReference |
||
| 481 | { |
||
| 482 | return new EdmPrimitiveTypeReference($this->getCoreModelPrimitiveType(PrimitiveTypeKind::Double()), $isNullable); |
||
| 483 | } |
||
| 484 | |||
| 485 | /** |
||
| 486 | * Gets a reference to a stream primitive type definition. |
||
| 487 | * |
||
| 488 | * @param bool $isNullable flag specifying if the referenced type should be nullable |
||
| 489 | * @return IPrimitiveTypeReference a new stream type reference |
||
| 490 | */ |
||
| 491 | public function getStream(bool $isNullable): IPrimitiveTypeReference |
||
| 492 | { |
||
| 493 | return new EdmPrimitiveTypeReference($this->getCoreModelPrimitiveType(PrimitiveTypeKind::Stream()), $isNullable); |
||
| 494 | } |
||
| 495 | |||
| 496 | /** |
||
| 497 | * Gets a reference to a temporal primitive type definition. |
||
| 498 | * |
||
| 499 | * @param PrimitiveTypeKind $kind primitive kind of the type reference being created |
||
| 500 | * @param int|null $precision precision of values of this type |
||
| 501 | * @param bool $isNullable flag specifying if the referenced type should be nullable |
||
| 502 | * @return ITemporalTypeReference a new temporal type reference |
||
| 503 | */ |
||
| 504 | public function getTemporal(PrimitiveTypeKind $kind, ?int $precision, bool $isNullable): ITemporalTypeReference |
||
| 505 | { |
||
| 506 | if ($kind->isTemporal()) { |
||
| 507 | return new EdmTemporalTypeReference($this->getCoreModelPrimitiveType($kind), $isNullable, $precision); |
||
| 508 | } |
||
| 509 | throw new InvalidOperationException(StringConst::EdmPrimitive_UnexpectedKind()); |
||
| 510 | } |
||
| 511 | |||
| 512 | /** |
||
| 513 | * Gets a reference to a binary primitive type definition. |
||
| 514 | * |
||
| 515 | * @param bool $isUnbounded flag specifying if max length is unbounded |
||
| 516 | * @param int|null $maxLength maximum length of the type |
||
| 517 | * @param bool|null $isFixedLength flag specifying if the type will have a fixed length |
||
| 518 | * @param bool $isNullable flag specifying if the referenced type should be nullable |
||
| 519 | * @return IBinaryTypeReference a new binary type reference |
||
| 520 | */ |
||
| 521 | public function getBinary(bool $isUnbounded, ?int $maxLength, ?bool $isFixedLength, bool $isNullable): IBinaryTypeReference |
||
| 524 | } |
||
| 525 | |||
| 526 | /** |
||
| 527 | * Gets a reference to a spatial primitive type definition. |
||
| 528 | * |
||
| 529 | * @param PrimitiveTypeKind $kind primitive kind of the type reference being created |
||
| 530 | * @param int|null $spatialReferenceIdentifier spatial Reference Identifier for the spatial type being created |
||
| 531 | * @param bool $isNullable flag specifying if the referenced type should be nullable |
||
| 532 | * @return ISpatialTypeReference a new spatial type reference |
||
| 533 | */ |
||
| 534 | public function getSpatial(PrimitiveTypeKind $kind, ?int $spatialReferenceIdentifier, bool $isNullable): ISpatialTypeReference |
||
| 535 | { |
||
| 536 | if ($kind->IsSpatial()) { |
||
| 537 | return new EdmSpatialTypeReference($this->getCoreModelPrimitiveType($kind), $isNullable, $spatialReferenceIdentifier); |
||
| 538 | } |
||
| 539 | throw new InvalidOperationException(StringConst::EdmPrimitive_UnexpectedKind()); |
||
| 540 | } |
||
| 541 | |||
| 542 | /** |
||
| 543 | * Gets a reference to a string primitive type definition. |
||
| 544 | * |
||
| 545 | * @param bool $isUnbounded flag specifying if max length is the maximum allowable value |
||
| 546 | * @param int|null $maxLength maximum length of the type |
||
| 547 | * @param bool|null $isFixedLength flag specifying if the type will have a fixed length |
||
| 548 | * @param bool|null $isUnicode flag specifying if the type should support unicode encoding |
||
| 549 | * @param string|null $collation string representing how data should be ordered |
||
| 550 | * @param bool $isNullable flag specifying if the referenced type should be nullable |
||
| 551 | * @return IStringTypeReference a new string type reference |
||
| 552 | */ |
||
| 553 | public function getString(bool $isUnbounded, ?int $maxLength, ?bool $isFixedLength, ?bool $isUnicode, ?string $collation, bool $isNullable): IStringTypeReference |
||
| 556 | } |
||
| 557 | } |
||
| 558 |