Complex classes like IronicSerialiser 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. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
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 IronicSerialiser, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 49 | class IronicSerialiser implements IObjectSerialiser |
||
| 50 | { |
||
| 51 | const PK = 'PrimaryKey'; |
||
| 52 | |||
| 53 | private $propertiesCache = []; |
||
| 54 | |||
| 55 | /** |
||
| 56 | * @var RootProjectionNode |
||
| 57 | */ |
||
| 58 | private $rootNode = null; |
||
| 59 | |||
| 60 | /** |
||
| 61 | * The service implementation. |
||
| 62 | * |
||
| 63 | * @var IService |
||
| 64 | */ |
||
| 65 | protected $service; |
||
| 66 | |||
| 67 | /** |
||
| 68 | * Request description instance describes OData request the |
||
| 69 | * the client has submitted and result of the request. |
||
| 70 | * |
||
| 71 | * @var RequestDescription |
||
| 72 | */ |
||
| 73 | protected $request; |
||
| 74 | |||
| 75 | /** |
||
| 76 | * Collection of complex type instances used for cycle detection. |
||
| 77 | * |
||
| 78 | * @var array |
||
| 79 | */ |
||
| 80 | protected $complexTypeInstanceCollection; |
||
| 81 | |||
| 82 | /** |
||
| 83 | * Absolute service Uri. |
||
| 84 | * |
||
| 85 | * @var string |
||
| 86 | */ |
||
| 87 | protected $absoluteServiceUri; |
||
| 88 | |||
| 89 | /** |
||
| 90 | * Absolute service Uri with slash. |
||
| 91 | * |
||
| 92 | * @var string |
||
| 93 | */ |
||
| 94 | protected $absoluteServiceUriWithSlash; |
||
| 95 | |||
| 96 | /** |
||
| 97 | * Holds reference to segment stack being processed. |
||
| 98 | * |
||
| 99 | * @var SegmentStack |
||
| 100 | */ |
||
| 101 | protected $stack; |
||
| 102 | |||
| 103 | /** |
||
| 104 | * Lightweight stack tracking for recursive descent fill. |
||
| 105 | */ |
||
| 106 | protected $lightStack = []; |
||
| 107 | |||
| 108 | /** |
||
| 109 | * @var ModelSerialiser |
||
| 110 | */ |
||
| 111 | private $modelSerialiser; |
||
| 112 | |||
| 113 | |||
| 114 | |||
| 115 | /** |
||
| 116 | * @var IMetadataProvider |
||
| 117 | */ |
||
| 118 | private $metaProvider; |
||
| 119 | |||
| 120 | /* |
||
| 121 | * Update time to insert into ODataEntry/ODataFeed fields |
||
| 122 | * @var Carbon; |
||
| 123 | */ |
||
| 124 | private $updated; |
||
| 125 | |||
| 126 | /* |
||
| 127 | * Has base URI already been written out during serialisation? |
||
| 128 | * @var bool; |
||
| 129 | */ |
||
| 130 | private $isBaseWritten = false; |
||
| 131 | |||
| 132 | /** |
||
| 133 | * @param IService $service Reference to the data service instance |
||
| 134 | * @param RequestDescription|null $request Type instance describing the client submitted request |
||
| 135 | */ |
||
| 136 | public function __construct(IService $service, RequestDescription $request = null) |
||
| 137 | { |
||
| 138 | $this->service = $service; |
||
| 139 | $this->request = $request; |
||
| 140 | $this->absoluteServiceUri = $service->getHost()->getAbsoluteServiceUri()->getUrlAsString(); |
||
| 141 | $this->absoluteServiceUriWithSlash = rtrim($this->absoluteServiceUri, '/') . '/'; |
||
| 142 | $this->stack = new SegmentStack($request); |
||
| 143 | $this->complexTypeInstanceCollection = []; |
||
| 144 | $this->modelSerialiser = new ModelSerialiser(); |
||
| 145 | $this->updated = Carbon::now(); |
||
| 146 | } |
||
| 147 | |||
| 148 | /** |
||
| 149 | * Write a top level entry resource. |
||
| 150 | * |
||
| 151 | * @param QueryResult $entryObject Reference to the entry object to be written |
||
| 152 | * |
||
| 153 | * @return ODataEntry|null |
||
| 154 | */ |
||
| 155 | public function writeTopLevelElement(QueryResult $entryObject) |
||
| 156 | { |
||
| 157 | if (!isset($entryObject->results)) { |
||
| 158 | array_pop($this->lightStack); |
||
| 159 | return null; |
||
| 160 | } |
||
| 161 | assert($entryObject instanceof QueryResult, get_class($entryObject)); |
||
| 162 | assert($entryObject->results instanceof Model, get_class($entryObject->results)); |
||
| 163 | $this->loadStackIfEmpty(); |
||
| 164 | |||
| 165 | $baseURI = $this->isBaseWritten ? null : $this->absoluteServiceUriWithSlash; |
||
| 166 | $this->isBaseWritten = true; |
||
| 167 | |||
| 168 | $stackCount = count($this->lightStack); |
||
| 169 | $topOfStack = $this->lightStack[$stackCount-1]; |
||
| 170 | $payloadClass = get_class($entryObject->results); |
||
| 171 | $resourceType = $this->getService()->getProvidersWrapper()->resolveResourceType($topOfStack['type']); |
||
| 172 | |||
| 173 | // need gubbinz to unpack an abstract resource type |
||
| 174 | $resourceType = $this->getConcreteTypeFromAbstractType($resourceType, $payloadClass); |
||
| 175 | |||
| 176 | // make sure we're barking up right tree |
||
| 177 | assert($resourceType instanceof ResourceEntityType, get_class($resourceType)); |
||
| 178 | $targClass = $resourceType->getInstanceType()->getName(); |
||
| 179 | assert( |
||
| 180 | $entryObject->results instanceof $targClass, |
||
| 181 | 'Object being serialised not instance of expected class, ' . $targClass . ', is actually ' . $payloadClass |
||
| 182 | ); |
||
| 183 | |||
| 184 | if (!array_key_exists($targClass, $this->propertiesCache)) { |
||
| 185 | $rawProp = $resourceType->getAllProperties(); |
||
| 186 | $relProp = []; |
||
| 187 | $nonRelProp = []; |
||
| 188 | foreach ($rawProp as $prop) { |
||
| 189 | $propType = $prop->getResourceType(); |
||
| 190 | if ($propType instanceof ResourceEntityType) { |
||
| 191 | $relProp[] = $prop; |
||
| 192 | } else { |
||
| 193 | $nonRelProp[$prop->getName()] = ['prop' => $prop, 'type' => $propType->getInstanceType()]; |
||
| 194 | } |
||
| 195 | } |
||
| 196 | $this->propertiesCache[$targClass] = ['rel' => $relProp, 'nonRel' => $nonRelProp]; |
||
| 197 | } |
||
| 198 | unset($relProp); |
||
| 199 | unset($nonRelProp); |
||
| 200 | $relProp = $this->propertiesCache[$targClass]['rel']; |
||
| 201 | $nonRelProp = $this->propertiesCache[$targClass]['nonRel']; |
||
| 202 | |||
| 203 | $resourceSet = $resourceType->getCustomState(); |
||
| 204 | assert($resourceSet instanceof ResourceSet); |
||
| 205 | $title = $resourceType->getName(); |
||
| 206 | $type = $resourceType->getFullName(); |
||
| 207 | |||
| 208 | $relativeUri = $this->getEntryInstanceKey( |
||
| 209 | $entryObject->results, |
||
| 210 | $resourceType, |
||
| 211 | $resourceSet->getName() |
||
| 212 | ); |
||
| 213 | $absoluteUri = rtrim($this->absoluteServiceUri, '/') . '/' . $relativeUri; |
||
| 214 | |||
| 215 | list($mediaLink, $mediaLinks) = $this->writeMediaData( |
||
| 216 | $entryObject->results, |
||
| 217 | $type, |
||
| 218 | $relativeUri, |
||
| 219 | $resourceType |
||
| 220 | ); |
||
| 221 | |||
| 222 | $propertyContent = $this->writePrimitiveProperties($entryObject->results, $nonRelProp); |
||
| 223 | |||
| 224 | $links = []; |
||
| 225 | foreach ($relProp as $prop) { |
||
| 226 | $nuLink = new ODataLink(); |
||
| 227 | $propKind = $prop->getKind(); |
||
| 228 | |||
| 229 | assert( |
||
| 230 | ResourcePropertyKind::RESOURCESET_REFERENCE == $propKind |
||
| 231 | || ResourcePropertyKind::RESOURCE_REFERENCE == $propKind, |
||
| 232 | '$propKind != ResourcePropertyKind::RESOURCESET_REFERENCE &&' |
||
| 233 | .' $propKind != ResourcePropertyKind::RESOURCE_REFERENCE' |
||
| 234 | ); |
||
| 235 | $propTail = ResourcePropertyKind::RESOURCE_REFERENCE == $propKind ? 'entry' : 'feed'; |
||
| 236 | $propType = 'application/atom+xml;type=' . $propTail; |
||
| 237 | $propName = $prop->getName(); |
||
| 238 | $nuLink->title = $propName; |
||
| 239 | $nuLink->name = ODataConstants::ODATA_RELATED_NAMESPACE . $propName; |
||
| 240 | $nuLink->url = $relativeUri . '/' . $propName; |
||
| 241 | $nuLink->type = $propType; |
||
| 242 | |||
| 243 | $navProp = new ODataNavigationPropertyInfo($prop, $this->shouldExpandSegment($propName)); |
||
| 244 | if ($navProp->expanded) { |
||
| 245 | $this->expandNavigationProperty($entryObject, $prop, $nuLink, $propKind, $propName); |
||
| 246 | } |
||
| 247 | |||
| 248 | $links[] = $nuLink; |
||
| 249 | } |
||
| 250 | |||
| 251 | $odata = new ODataEntry(); |
||
| 252 | $odata->resourceSetName = $resourceSet->getName(); |
||
| 253 | $odata->id = $absoluteUri; |
||
| 254 | $odata->title = new ODataTitle($title); |
||
| 255 | $odata->type = new ODataCategory($type); |
||
| 256 | $odata->propertyContent = $propertyContent; |
||
| 257 | $odata->isMediaLinkEntry = $resourceType->isMediaLinkEntry(); |
||
| 258 | $odata->editLink = new ODataLink(); |
||
| 259 | $odata->editLink->url = $relativeUri; |
||
| 260 | $odata->editLink->name = 'edit'; |
||
| 261 | $odata->editLink->title = $title; |
||
| 262 | $odata->mediaLink = $mediaLink; |
||
| 263 | $odata->mediaLinks = $mediaLinks; |
||
| 264 | $odata->links = $links; |
||
| 265 | $odata->updated = $this->getUpdated()->format(DATE_ATOM); |
||
| 266 | $odata->baseURI = $baseURI; |
||
| 267 | |||
| 268 | $newCount = count($this->lightStack); |
||
| 269 | assert( |
||
| 270 | $newCount == $stackCount, |
||
| 271 | 'Should have ' . $stackCount . ' elements in stack, have ' . $newCount . ' elements' |
||
| 272 | ); |
||
| 273 | $this->lightStack[$newCount-1]['count']--; |
||
| 274 | if (0 == $this->lightStack[$newCount-1]['count']) { |
||
| 275 | array_pop($this->lightStack); |
||
| 276 | } |
||
| 277 | return $odata; |
||
| 278 | } |
||
| 279 | |||
| 280 | /** |
||
| 281 | * Write top level feed element. |
||
| 282 | * |
||
| 283 | * @param QueryResult &$entryObjects Array of entry resources to be written |
||
| 284 | * |
||
| 285 | * @return ODataFeed |
||
| 286 | */ |
||
| 287 | public function writeTopLevelElements(QueryResult & $entryObjects) |
||
| 288 | { |
||
| 289 | $res = $entryObjects->results; |
||
| 290 | assert(is_array($res) || $res instanceof Collection, '!is_array($entryObjects->results)'); |
||
| 291 | |||
| 292 | $this->loadStackIfEmpty(); |
||
| 293 | $setName = $this->getRequest()->getTargetResourceSetWrapper()->getName(); |
||
| 294 | |||
| 295 | $title = $this->getRequest()->getContainerName(); |
||
| 296 | $relativeUri = $this->getRequest()->getIdentifier(); |
||
| 297 | $absoluteUri = $this->getRequest()->getRequestUrl()->getUrlAsString(); |
||
| 298 | |||
| 299 | $selfLink = new ODataLink(); |
||
| 300 | $selfLink->name = 'self'; |
||
| 301 | $selfLink->title = $relativeUri; |
||
| 302 | $selfLink->url = $relativeUri; |
||
| 303 | |||
| 304 | $odata = new ODataFeed(); |
||
| 305 | $odata->title = new ODataTitle($title); |
||
| 306 | $odata->id = $absoluteUri; |
||
| 307 | $odata->selfLink = $selfLink; |
||
| 308 | $odata->updated = $this->getUpdated()->format(DATE_ATOM); |
||
| 309 | $odata->baseURI = $this->isBaseWritten ? null : $this->absoluteServiceUriWithSlash; |
||
| 310 | $this->isBaseWritten = true; |
||
| 311 | |||
| 312 | if ($this->getRequest()->queryType == QueryType::ENTITIES_WITH_COUNT()) { |
||
| 313 | $odata->rowCount = $this->getRequest()->getCountValue(); |
||
| 314 | } |
||
| 315 | foreach ($res as $entry) { |
||
| 316 | if (!$entry instanceof QueryResult) { |
||
| 317 | $query = new QueryResult(); |
||
| 318 | $query->results = $entry; |
||
| 319 | } else { |
||
| 320 | $query = $entry; |
||
| 321 | } |
||
| 322 | assert($query instanceof QueryResult, get_class($query)); |
||
| 323 | assert($query->results instanceof Model, get_class($query->results)); |
||
| 324 | $odata->entries[] = $this->writeTopLevelElement($query); |
||
| 325 | } |
||
| 326 | |||
| 327 | $resourceSet = $this->getRequest()->getTargetResourceSetWrapper()->getResourceSet(); |
||
| 328 | $requestTop = $this->getRequest()->getTopOptionCount(); |
||
| 329 | $pageSize = $this->getService()->getConfiguration()->getEntitySetPageSize($resourceSet); |
||
| 330 | $requestTop = (null === $requestTop) ? $pageSize+1 : $requestTop; |
||
| 331 | |||
| 332 | if (true === $entryObjects->hasMore && $requestTop > $pageSize) { |
||
| 333 | $stackSegment = $setName; |
||
| 334 | $lastObject = end($entryObjects->results); |
||
| 335 | $segment = $this->getNextLinkUri($lastObject); |
||
| 336 | $nextLink = new ODataLink(); |
||
| 337 | $nextLink->name = ODataConstants::ATOM_LINK_NEXT_ATTRIBUTE_STRING; |
||
| 338 | $nextLink->url = rtrim($this->absoluteServiceUri, '/') . '/' . $stackSegment . $segment; |
||
| 339 | $odata->nextPageLink = $nextLink; |
||
| 340 | } |
||
| 341 | |||
| 342 | return $odata; |
||
| 343 | } |
||
| 344 | |||
| 345 | /** |
||
| 346 | * Write top level url element. |
||
| 347 | * |
||
| 348 | * @param QueryResult $entryObject The entry resource whose url to be written |
||
| 349 | * |
||
| 350 | * @return ODataURL |
||
| 351 | */ |
||
| 352 | public function writeUrlElement(QueryResult $entryObject) |
||
| 353 | { |
||
| 354 | $url = new ODataURL(); |
||
| 355 | if (null !== $entryObject->results) { |
||
| 356 | $currentResourceType = $this->getCurrentResourceSetWrapper()->getResourceType(); |
||
| 357 | $relativeUri = $this->getEntryInstanceKey( |
||
| 358 | $entryObject->results, |
||
| 359 | $currentResourceType, |
||
| 360 | $this->getCurrentResourceSetWrapper()->getName() |
||
| 361 | ); |
||
| 362 | |||
| 363 | $url->url = rtrim($this->absoluteServiceUri, '/') . '/' . $relativeUri; |
||
| 364 | } |
||
| 365 | |||
| 366 | return $url; |
||
| 367 | } |
||
| 368 | |||
| 369 | /** |
||
| 370 | * Write top level url collection. |
||
| 371 | * |
||
| 372 | * @param QueryResult $entryObjects Array of entry resources whose url to be written |
||
| 373 | * |
||
| 374 | * @return ODataURLCollection |
||
| 375 | */ |
||
| 376 | public function writeUrlElements(QueryResult $entryObjects) |
||
| 377 | { |
||
| 378 | $urls = new ODataURLCollection(); |
||
| 379 | if (!empty($entryObjects->results)) { |
||
| 380 | $i = 0; |
||
| 381 | foreach ($entryObjects->results as $entryObject) { |
||
| 382 | if (!$entryObject instanceof QueryResult) { |
||
| 383 | $query = new QueryResult(); |
||
| 384 | $query->results = $entryObject; |
||
| 385 | } else { |
||
| 386 | $query = $entryObject; |
||
| 387 | } |
||
| 388 | $urls->urls[$i] = $this->writeUrlElement($query); |
||
| 389 | ++$i; |
||
| 390 | } |
||
| 391 | |||
| 392 | if ($i > 0 && true === $entryObjects->hasMore) { |
||
| 393 | $stackSegment = $this->getRequest()->getTargetResourceSetWrapper()->getName(); |
||
| 394 | $lastObject = end($entryObjects->results); |
||
| 395 | $segment = $this->getNextLinkUri($lastObject); |
||
| 396 | $nextLink = new ODataLink(); |
||
| 397 | $nextLink->name = ODataConstants::ATOM_LINK_NEXT_ATTRIBUTE_STRING; |
||
| 398 | $nextLink->url = rtrim($this->absoluteServiceUri, '/') . '/' . $stackSegment . $segment; |
||
| 399 | $urls->nextPageLink = $nextLink; |
||
| 400 | } |
||
| 401 | } |
||
| 402 | |||
| 403 | if ($this->getRequest()->queryType == QueryType::ENTITIES_WITH_COUNT()) { |
||
| 404 | $urls->count = $this->getRequest()->getCountValue(); |
||
| 405 | } |
||
| 406 | |||
| 407 | return $urls; |
||
| 408 | } |
||
| 409 | |||
| 410 | /** |
||
| 411 | * Write top level complex resource. |
||
| 412 | * |
||
| 413 | * @param QueryResult &$complexValue The complex object to be written |
||
| 414 | * @param string $propertyName The name of the complex property |
||
| 415 | * @param ResourceType &$resourceType Describes the type of complex object |
||
| 416 | * |
||
| 417 | * @return ODataPropertyContent |
||
| 418 | */ |
||
| 419 | public function writeTopLevelComplexObject(QueryResult & $complexValue, $propertyName, ResourceType & $resourceType) |
||
| 420 | { |
||
| 421 | $result = $complexValue->results; |
||
| 422 | |||
| 423 | $propertyContent = new ODataPropertyContent(); |
||
| 424 | $odataProperty = new ODataProperty(); |
||
| 425 | $odataProperty->name = $propertyName; |
||
| 426 | $odataProperty->typeName = $resourceType->getFullName(); |
||
| 427 | if (null != $result) { |
||
| 428 | $internalContent = $this->writeComplexValue($resourceType, $result); |
||
|
|
|||
| 429 | $odataProperty->value = $internalContent; |
||
| 430 | } |
||
| 431 | |||
| 432 | $propertyContent->properties[$propertyName] = $odataProperty; |
||
| 433 | |||
| 434 | return $propertyContent; |
||
| 435 | } |
||
| 436 | |||
| 437 | /** |
||
| 438 | * Write top level bag resource. |
||
| 439 | * |
||
| 440 | * @param QueryResult &$BagValue The bag object to be |
||
| 441 | * written |
||
| 442 | * @param string $propertyName The name of the |
||
| 443 | * bag property |
||
| 444 | * @param ResourceType &$resourceType Describes the type of |
||
| 445 | * bag object |
||
| 446 | * |
||
| 447 | * @return ODataPropertyContent |
||
| 448 | */ |
||
| 449 | public function writeTopLevelBagObject(QueryResult & $BagValue, $propertyName, ResourceType & $resourceType) |
||
| 462 | |||
| 463 | /** |
||
| 464 | * Write top level primitive value. |
||
| 465 | * |
||
| 466 | * @param QueryResult &$primitiveValue The primitive value to be |
||
| 467 | * written |
||
| 468 | * @param ResourceProperty &$resourceProperty Resource property describing the |
||
| 469 | * primitive property to be written |
||
| 470 | * @return ODataPropertyContent |
||
| 471 | */ |
||
| 472 | public function writeTopLevelPrimitive(QueryResult & $primitiveValue, ResourceProperty & $resourceProperty = null) |
||
| 473 | { |
||
| 474 | assert(null != $resourceProperty, 'Resource property must not be null'); |
||
| 475 | $propertyContent = new ODataPropertyContent(); |
||
| 476 | |||
| 477 | $odataProperty = new ODataProperty(); |
||
| 478 | $odataProperty->name = $resourceProperty->getName(); |
||
| 479 | $iType = $resourceProperty->getInstanceType(); |
||
| 480 | assert($iType instanceof IType, get_class($iType)); |
||
| 481 | $odataProperty->typeName = $iType->getFullTypeName(); |
||
| 482 | if (null == $primitiveValue->results) { |
||
| 483 | $odataProperty->value = null; |
||
| 484 | } else { |
||
| 485 | $rType = $resourceProperty->getResourceType()->getInstanceType(); |
||
| 486 | assert($rType instanceof IType, get_class($rType)); |
||
| 487 | $odataProperty->value = $this->primitiveToString($rType, $primitiveValue->results); |
||
| 488 | } |
||
| 489 | |||
| 490 | $propertyContent->properties[$odataProperty->name] = $odataProperty; |
||
| 491 | |||
| 492 | return $propertyContent; |
||
| 493 | } |
||
| 494 | |||
| 495 | /** |
||
| 496 | * Gets reference to the request submitted by client. |
||
| 497 | * |
||
| 498 | * @return RequestDescription |
||
| 499 | */ |
||
| 500 | public function getRequest() |
||
| 506 | |||
| 507 | /** |
||
| 508 | * Sets reference to the request submitted by client. |
||
| 509 | * |
||
| 510 | * @param RequestDescription $request |
||
| 511 | */ |
||
| 512 | public function setRequest(RequestDescription $request) |
||
| 517 | |||
| 518 | /** |
||
| 519 | * Gets the data service instance. |
||
| 520 | * |
||
| 521 | * @return IService |
||
| 522 | */ |
||
| 523 | public function getService() |
||
| 527 | |||
| 528 | /** |
||
| 529 | * Gets the segment stack instance. |
||
| 530 | * |
||
| 531 | * @return SegmentStack |
||
| 532 | */ |
||
| 533 | public function getStack() |
||
| 537 | |||
| 538 | /** |
||
| 539 | * Get update timestamp. |
||
| 540 | * |
||
| 541 | * @return Carbon |
||
| 542 | */ |
||
| 543 | public function getUpdated() |
||
| 547 | |||
| 548 | protected function getEntryInstanceKey($entityInstance, ResourceType $resourceType, $containerName) |
||
| 575 | |||
| 576 | /** |
||
| 577 | * @param $entryObject |
||
| 578 | * @param $type |
||
| 579 | * @param $relativeUri |
||
| 580 | * @param $resourceType |
||
| 581 | * @return array<ODataMediaLink|null|array> |
||
| 582 | */ |
||
| 583 | protected function writeMediaData($entryObject, $type, $relativeUri, ResourceType $resourceType) |
||
| 621 | |||
| 622 | /** |
||
| 623 | * Gets collection of projection nodes under the current node. |
||
| 624 | * |
||
| 625 | * @return ProjectionNode[]|ExpandedProjectionNode[]|null List of nodes describing projections for the current |
||
| 626 | * segment, If this method returns null it means no |
||
| 627 | * projections are to be applied and the entire resource for |
||
| 628 | * the current segment should be serialized, If it returns |
||
| 629 | * non-null only the properties described by the returned |
||
| 630 | * projection segments should be serialized |
||
| 631 | */ |
||
| 632 | protected function getProjectionNodes() |
||
| 641 | |||
| 642 | /** |
||
| 643 | * Find a 'ExpandedProjectionNode' instance in the projection tree |
||
| 644 | * which describes the current segment. |
||
| 645 | * |
||
| 646 | * @return null|RootProjectionNode|ExpandedProjectionNode |
||
| 647 | */ |
||
| 648 | protected function getCurrentExpandedProjectionNode() |
||
| 679 | |||
| 680 | /** |
||
| 681 | * Check whether to expand a navigation property or not. |
||
| 682 | * |
||
| 683 | * @param string $navigationPropertyName Name of naviagtion property in question |
||
| 684 | * |
||
| 685 | * @return bool True if the given navigation should be expanded, otherwise false |
||
| 686 | */ |
||
| 687 | protected function shouldExpandSegment($navigationPropertyName) |
||
| 698 | |||
| 699 | /** |
||
| 700 | * Wheter next link is needed for the current resource set (feed) |
||
| 701 | * being serialized. |
||
| 702 | * |
||
| 703 | * @param int $resultSetCount Number of entries in the current |
||
| 704 | * resource set |
||
| 705 | * |
||
| 706 | * @return bool true if the feed must have a next page link |
||
| 707 | */ |
||
| 708 | protected function needNextPageLink($resultSetCount) |
||
| 723 | |||
| 724 | /** |
||
| 725 | * Resource set wrapper for the resource being serialized. |
||
| 726 | * |
||
| 727 | * @return ResourceSetWrapper |
||
| 728 | */ |
||
| 729 | protected function getCurrentResourceSetWrapper() |
||
| 736 | |||
| 737 | /** |
||
| 738 | * Get next page link from the given entity instance. |
||
| 739 | * |
||
| 740 | * @param mixed &$lastObject Last object serialized to be |
||
| 741 | * used for generating |
||
| 742 | * $skiptoken |
||
| 743 | * @throws ODataException |
||
| 744 | * @return string for the link for next page |
||
| 745 | */ |
||
| 746 | protected function getNextLinkUri(&$lastObject) |
||
| 764 | |||
| 765 | /** |
||
| 766 | * Builds the string corresponding to query parameters for top level results |
||
| 767 | * (result set identified by the resource path) to be put in next page link. |
||
| 768 | * |
||
| 769 | * @return string|null string representing the query parameters in the URI |
||
| 770 | * query parameter format, NULL if there |
||
| 771 | * is no query parameters |
||
| 772 | * required for the next link of top level result set |
||
| 773 | */ |
||
| 774 | protected function getNextPageLinkQueryParametersForRootResourceSet() |
||
| 810 | |||
| 811 | private function loadStackIfEmpty() |
||
| 818 | |||
| 819 | /** |
||
| 820 | * Convert the given primitive value to string. |
||
| 821 | * Note: This method will not handle null primitive value. |
||
| 822 | * |
||
| 823 | * @param IType &$primitiveResourceType Type of the primitive property |
||
| 824 | * whose value need to be converted |
||
| 825 | * @param mixed $primitiveValue Primitive value to convert |
||
| 826 | * |
||
| 827 | * @return string |
||
| 828 | */ |
||
| 829 | private function primitiveToString(IType & $type, $primitiveValue) |
||
| 852 | |||
| 853 | /** |
||
| 854 | * @param $entryObject |
||
| 855 | * @param $nonRelProp |
||
| 856 | * @return ODataPropertyContent |
||
| 857 | */ |
||
| 858 | private function writePrimitiveProperties(Model $entryObject, $nonRelProp) |
||
| 876 | |||
| 877 | /** |
||
| 878 | * @param $entryObject |
||
| 879 | * @param $prop |
||
| 880 | * @param $nuLink |
||
| 881 | * @param $propKind |
||
| 882 | * @param $propName |
||
| 883 | */ |
||
| 884 | private function expandNavigationProperty(QueryResult $entryObject, $prop, $nuLink, $propKind, $propName) |
||
| 921 | |||
| 922 | /** |
||
| 923 | * Gets the data service instance. |
||
| 924 | * |
||
| 925 | * @return void |
||
| 926 | */ |
||
| 927 | public function setService(IService $service) |
||
| 933 | |||
| 934 | /** |
||
| 935 | * @param ResourceType $resourceType |
||
| 936 | * @param $result |
||
| 937 | * @return ODataBagContent|null |
||
| 938 | */ |
||
| 939 | protected function writeBagValue(ResourceType & $resourceType, $result) |
||
| 965 | |||
| 966 | /** |
||
| 967 | * @param ResourceType $resourceType |
||
| 968 | * @param object $result |
||
| 969 | * @param string|null $propertyName |
||
| 970 | * @return ODataPropertyContent |
||
| 971 | */ |
||
| 972 | protected function writeComplexValue(ResourceType & $resourceType, &$result, $propertyName = null) |
||
| 1017 | |||
| 1018 | public static function isMatchPrimitive($resourceKind) |
||
| 1028 | |||
| 1029 | /* |
||
| 1030 | * @return IMetadataProvider |
||
| 1031 | */ |
||
| 1032 | protected function getMetadata() |
||
| 1039 | |||
| 1040 | /** |
||
| 1041 | * @return array |
||
| 1042 | */ |
||
| 1043 | protected function getLightStack() |
||
| 1047 | |||
| 1048 | /** |
||
| 1049 | * @return ModelSerialiser |
||
| 1050 | */ |
||
| 1051 | public function getModelSerialiser() |
||
| 1055 | |||
| 1056 | protected function getConcreteTypeFromAbstractType(ResourceEntityType $resourceType, $payloadClass) |
||
| 1076 | } |
||
| 1077 |
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.