Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
Complex classes like RequestDescription 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 RequestDescription, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 32 | class RequestDescription |
||
| 33 | { |
||
| 34 | /** |
||
| 35 | * Holds the value of HTTP 'DataServiceVersion' header in the request, |
||
| 36 | * DataServiceVersion header value states the version of the |
||
| 37 | * Open Data Protocol used by the client to generate the request. |
||
| 38 | * Refer http://www.odata.org/developers/protocols/overview#ProtocolVersioning |
||
| 39 | * |
||
| 40 | * @var Version |
||
| 41 | */ |
||
| 42 | private $requestVersion = null; |
||
| 43 | |||
| 44 | /** |
||
| 45 | * Holds the value of HTTP 'MaxDataServiceVersion' header in the request, |
||
| 46 | * MaxDataServiceVersion header value specifies the maximum version number |
||
| 47 | * the client can accept in a response. |
||
| 48 | * Refer http://www.odata.org/developers/protocols/overview#ProtocolVersioning |
||
| 49 | * |
||
| 50 | * @var Version |
||
| 51 | */ |
||
| 52 | private $requestMaxVersion = null; |
||
| 53 | |||
| 54 | /** |
||
| 55 | * This is the value of 'DataServiceVersion' header to be output in the response. this header |
||
| 56 | * value states the OData version the server used to generate the response. |
||
| 57 | * While processing the query and result set this value will be keeps on |
||
| 58 | * updating, after every update this is compared against the |
||
| 59 | * 'MaxDataServiceVersion' header in the client request to see whether the |
||
| 60 | * client can interpret the response or not. The client should use this |
||
| 61 | * value to determine whether it can correctly interpret the response or not. |
||
| 62 | * Refer http://www.odata.org/developers/protocols/overview#ProtocolVersioning |
||
| 63 | * |
||
| 64 | * @var Version |
||
| 65 | */ |
||
| 66 | private $requiredMinResponseVersion; |
||
| 67 | |||
| 68 | /** |
||
| 69 | * The minimum client version requirement, This value keeps getting updated |
||
| 70 | * during processing of query, this is compared against the |
||
| 71 | * DataServiceVersion header in the client request and if the client request |
||
| 72 | * is less than this value then we fail the request (e.g. $count request |
||
| 73 | * was sent but client said it was Version 1.0). |
||
| 74 | * |
||
| 75 | * @var Version |
||
| 76 | */ |
||
| 77 | private $requiredMinRequestVersion; |
||
| 78 | |||
| 79 | /** @var Version */ |
||
| 80 | private $maxServiceVersion; |
||
| 81 | |||
| 82 | /** |
||
| 83 | * Collection of known data service versions. |
||
| 84 | * |
||
| 85 | * @var Version[] |
||
| 86 | */ |
||
| 87 | private static $_knownDataServiceVersions = null; |
||
| 88 | |||
| 89 | /** |
||
| 90 | * |
||
| 91 | * @var Url |
||
| 92 | */ |
||
| 93 | private $requestUrl; |
||
| 94 | |||
| 95 | /** |
||
| 96 | * Collection of SegmentDescriptor containing information about |
||
| 97 | * each segment in the resource path part of the request uri. |
||
| 98 | * |
||
| 99 | * @var SegmentDescriptor[] |
||
| 100 | */ |
||
| 101 | private $segments; |
||
| 102 | |||
| 103 | /** |
||
| 104 | * Holds reference to the last segment descriptor. |
||
| 105 | * |
||
| 106 | * @var SegmentDescriptor |
||
| 107 | */ |
||
| 108 | private $lastSegment; |
||
| 109 | |||
| 110 | /** |
||
| 111 | * The name of the container for results |
||
| 112 | * |
||
| 113 | * @var string|null |
||
| 114 | */ |
||
| 115 | private $_containerName; |
||
| 116 | |||
| 117 | |||
| 118 | /** |
||
| 119 | * The count option specified in the request. |
||
| 120 | * |
||
| 121 | * @var QueryType |
||
| 122 | */ |
||
| 123 | public $queryType; |
||
| 124 | |||
| 125 | /** |
||
| 126 | * Number of segments. |
||
| 127 | * |
||
| 128 | * @var int |
||
| 129 | */ |
||
| 130 | private $_segmentCount; |
||
| 131 | |||
| 132 | /** |
||
| 133 | * Holds the value of $skip query option, if no $skip option |
||
| 134 | * found then this parameter will be NULL. |
||
| 135 | * |
||
| 136 | * @var int|null |
||
| 137 | */ |
||
| 138 | private $_skipCount; |
||
| 139 | |||
| 140 | /** |
||
| 141 | * Holds the value of take count, this value is depends on |
||
| 142 | * presence of $top option and configured page size. |
||
| 143 | * |
||
| 144 | * @var int|null |
||
| 145 | */ |
||
| 146 | private $_topCount; |
||
| 147 | |||
| 148 | /** |
||
| 149 | * Holds the value of $top query option, if no $top option |
||
| 150 | * found then this parameter will be NULL. |
||
| 151 | * |
||
| 152 | * @var int|null |
||
| 153 | */ |
||
| 154 | private $_topOptionCount; |
||
| 155 | |||
| 156 | /** |
||
| 157 | * Holds the parsed details for sorting, this will |
||
| 158 | * be set in 3 cases |
||
| 159 | * (1) if $orderby option is specified in the request uri |
||
| 160 | * (2) if $skip or $top option is specified in the request uri |
||
| 161 | * (3) if server side paging is enabled for the resource |
||
| 162 | * targeted by the request uri. |
||
| 163 | * |
||
| 164 | * @var InternalOrderByInfo|null |
||
| 165 | */ |
||
| 166 | private $internalOrderByInfo; |
||
| 167 | |||
| 168 | /** |
||
| 169 | * Holds the parsed details for $skiptoken option, this will |
||
| 170 | * be NULL if $skiptoken option is absent. |
||
| 171 | * |
||
| 172 | * @var InternalSkipTokenInfo|null |
||
| 173 | */ |
||
| 174 | private $_internalSkipTokenInfo; |
||
| 175 | |||
| 176 | /** |
||
| 177 | * Holds the parsed details for $filter option, this will be NULL if $filter option is absent. |
||
| 178 | * |
||
| 179 | * @var FilterInfo|null |
||
| 180 | */ |
||
| 181 | private $_filterInfo; |
||
| 182 | |||
| 183 | /** |
||
| 184 | * Holds reference to the root of the tree describing expand |
||
| 185 | * and select information, this field will be NULL if no |
||
| 186 | * $expand or $select specified in the request uri. |
||
| 187 | * |
||
| 188 | * @var RootProjectionNode|null |
||
| 189 | */ |
||
| 190 | private $_rootProjectionNode; |
||
| 191 | |||
| 192 | /** |
||
| 193 | * Holds number of entities in the result set, if either $count or |
||
| 194 | * $inlinecount=allpages is specified, otherwise NULL |
||
| 195 | * |
||
| 196 | * |
||
| 197 | * @var int|null |
||
| 198 | */ |
||
| 199 | private $_countValue; |
||
| 200 | |||
| 201 | /** |
||
| 202 | * Data of request from request body |
||
| 203 | * |
||
| 204 | * @var array |
||
| 205 | */ |
||
| 206 | private $_data; |
||
| 207 | |||
| 208 | /** |
||
| 209 | * Flag indicating status of query execution. |
||
| 210 | * |
||
| 211 | * @var boolean |
||
| 212 | */ |
||
| 213 | private $_isExecuted; |
||
| 214 | |||
| 215 | /** |
||
| 216 | * Reference to Uri processor. |
||
| 217 | * |
||
| 218 | * @var UriProcessor |
||
| 219 | */ |
||
| 220 | private $_uriProcessor; |
||
| 221 | |||
| 222 | |||
| 223 | /** |
||
| 224 | * Reference to the service |
||
| 225 | * @var IService |
||
| 226 | */ |
||
| 227 | private $_service; |
||
| 228 | |||
| 229 | /** |
||
| 230 | * The parts of a multipart request |
||
| 231 | * @var array |
||
| 232 | */ |
||
| 233 | private $_parts; |
||
| 234 | |||
| 235 | /** |
||
| 236 | * @param SegmentDescriptor[] $segmentDescriptors Description of segments in the resource path. |
||
| 237 | * @param Url $requestUri |
||
| 238 | * @param Version $serviceMaxVersion |
||
| 239 | * @param null|string $requestVersion |
||
| 240 | * @param null|string $maxRequestVersion |
||
| 241 | * @param string $dataType |
||
| 242 | */ |
||
| 243 | public function __construct($segmentDescriptors, Url $requestUri, Version $serviceMaxVersion, $requestVersion, $maxRequestVersion, $dataType = null, IService $service = null) |
||
| 301 | |||
| 302 | public function getParts() { |
||
| 305 | |||
| 306 | /** |
||
| 307 | * Define request data from body |
||
| 308 | * @param string $dataType |
||
| 309 | */ |
||
| 310 | private function _readData($dataType) { |
||
| 386 | |||
| 387 | /** |
||
| 388 | * Get request data from body |
||
| 389 | */ |
||
| 390 | public function getData() { |
||
| 393 | |||
| 394 | /** |
||
| 395 | * Raise the minimum client version requirement for this request and |
||
| 396 | * perform capability negotiation. |
||
| 397 | * |
||
| 398 | * @param int $major The major segment of the version |
||
| 399 | * @param int $minor The minor segment of the version |
||
| 400 | * |
||
| 401 | * @throws ODataException If capability negotiation fails. |
||
| 402 | */ |
||
| 403 | public function raiseMinVersionRequirement($major, $minor) { |
||
| 409 | |||
| 410 | /** |
||
| 411 | * Raise the response version for this request and perform capability negotiation. |
||
| 412 | * |
||
| 413 | * |
||
| 414 | * @param int $major The major segment of the version |
||
| 415 | * @param int $minor The minor segment of the version |
||
| 416 | * |
||
| 417 | * @throws ODataException If capability negotiation fails. |
||
| 418 | */ |
||
| 419 | public function raiseResponseVersion($major, $minor) { |
||
| 425 | |||
| 426 | /** |
||
| 427 | * Gets collection of segment descriptors containing information about |
||
| 428 | * each segment in the resource path part of the request uri. |
||
| 429 | * |
||
| 430 | * @return SegmentDescriptor[] |
||
| 431 | */ |
||
| 432 | public function getSegments() |
||
| 436 | |||
| 437 | /** |
||
| 438 | * Gets reference to the descriptor of last segment. |
||
| 439 | * |
||
| 440 | * @return SegmentDescriptor |
||
| 441 | */ |
||
| 442 | public function getLastSegment() |
||
| 446 | |||
| 447 | /** |
||
| 448 | * Gets kind of resource targeted by the resource path. |
||
| 449 | * |
||
| 450 | * @return TargetKind |
||
| 451 | */ |
||
| 452 | public function getTargetKind() |
||
| 456 | |||
| 457 | /** |
||
| 458 | * Gets kind of 'source of data' targeted by the resource path. |
||
| 459 | * |
||
| 460 | * @return TargetSource |
||
| 461 | */ |
||
| 462 | public function getTargetSource() |
||
| 475 | |||
| 476 | /** |
||
| 477 | * Gets reference to the ResourceSetWrapper instance targeted by |
||
| 478 | * the resource path, ResourceSetWrapper will present in the |
||
| 479 | * following cases: |
||
| 480 | * if the last segment descriptor describes |
||
| 481 | * (a) resource set |
||
| 482 | * http://server/NW.svc/Customers |
||
| 483 | * http://server/NW.svc/Customers('ALFKI') |
||
| 484 | * http://server/NW.svc/Customers('ALFKI')/Orders |
||
| 485 | * http://server/NW.svc/Customers('ALFKI')/Orders(123) |
||
| 486 | * http://server/NW.svc/Customers('ALFKI')/$links/Orders |
||
| 487 | * (b) resource set reference |
||
| 488 | * http://server/NW.svc/Orders(123)/Customer |
||
| 489 | * http://server/NW.svc/Orders(123)/$links/Customer |
||
| 490 | * (c) $count |
||
| 491 | * http://server/NW.svc/Customers/$count |
||
| 492 | * ResourceSet wrapper will be absent (NULL) in the following cases: |
||
| 493 | * if the last segment descriptor describes |
||
| 494 | * (a) Primitive |
||
| 495 | * http://server/NW.svc/Customers('ALFKI')/Country |
||
| 496 | * (b) $value on primitive type |
||
| 497 | * http://server/NW.svc/Customers('ALFKI')/Country/$value |
||
| 498 | * (c) Complex |
||
| 499 | * http://server/NW.svc/Customers('ALFKI')/Address |
||
| 500 | * (d) Bag |
||
| 501 | * http://server/NW.svc/Employees(123)/Emails |
||
| 502 | * (e) MLE |
||
| 503 | * http://server/NW.svc/Employees(123)/$value |
||
| 504 | * (f) Named Stream |
||
| 505 | * http://server/NW.svc/Employees(123)/Thumnail48_48 |
||
| 506 | * (g) metadata |
||
| 507 | * http://server/NW.svc/$metadata |
||
| 508 | * (h) service directory |
||
| 509 | * http://server/NW.svc |
||
| 510 | * (i) $bath |
||
| 511 | * http://server/NW.svc/$batch |
||
| 512 | * |
||
| 513 | * @return ResourceSetWrapper|null |
||
| 514 | */ |
||
| 515 | public function getTargetResourceSetWrapper() |
||
| 519 | |||
| 520 | /** |
||
| 521 | * Gets reference to the ResourceType instance targeted by |
||
| 522 | * the resource path, ResourceType will present in the |
||
| 523 | * following cases: |
||
| 524 | * if the last segment descriptor describes |
||
| 525 | * (a) resource set |
||
| 526 | * http://server/NW.svc/Customers |
||
| 527 | * http://server/NW.svc/Customers('ALFKI') |
||
| 528 | * http://server/NW.svc/Customers('ALFKI')/Orders |
||
| 529 | * http://server/NW.svc/Customers('ALFKI')/Orders(123) |
||
| 530 | * http://server/NW.svc/Customers('ALFKI')/$links/Orders |
||
| 531 | * (b) resource set reference |
||
| 532 | * http://server/NW.svc/Orders(123)/Customer |
||
| 533 | * http://server/NW.svc/Orders(123)/$links/Customer |
||
| 534 | * (c) $count |
||
| 535 | * http://server/NW.svc/Customers/$count |
||
| 536 | * (d) Primitive |
||
| 537 | * http://server/NW.svc/Customers('ALFKI')/Country |
||
| 538 | * (e) $value on primitive type |
||
| 539 | * http://server/NW.svc/Customers('ALFKI')/Country/$value |
||
| 540 | * (f) Complex |
||
| 541 | * http://server/NW.svc/Customers('ALFKI')/Address |
||
| 542 | * (g) Bag |
||
| 543 | * http://server/NW.svc/Employees(123)/Emails |
||
| 544 | * (h) MLE |
||
| 545 | * http://server/NW.svc/Employees(123)/$value |
||
| 546 | * (i) Named Stream |
||
| 547 | * http://server/NW.svc/Employees(123)/Thumnail48_48 |
||
| 548 | * ResourceType will be absent (NULL) in the following cases: |
||
| 549 | * if the last segment descriptor describes |
||
| 550 | * (a) metadata |
||
| 551 | * http://server/NW.svc/$metadata |
||
| 552 | * (b) service directory |
||
| 553 | * http://server/NW.svc |
||
| 554 | * (c) $bath |
||
| 555 | * http://server/NW.svc/$batch |
||
| 556 | * |
||
| 557 | * @return ResourceType|null |
||
| 558 | */ |
||
| 559 | public function getTargetResourceType() |
||
| 563 | |||
| 564 | /** |
||
| 565 | * Gets reference to the ResourceProperty instance targeted by |
||
| 566 | * the resource path, ResourceProperty will present in the |
||
| 567 | * following cases: |
||
| 568 | * if the last segment descriptor describes |
||
| 569 | * (a) resource set (after 1 level) |
||
| 570 | * http://server/NW.svc/Customers('ALFKI')/Orders |
||
| 571 | * http://server/NW.svc/Customers('ALFKI')/Orders(123) |
||
| 572 | * http://server/NW.svc/Customers('ALFKI')/$links/Orders |
||
| 573 | * (b) resource set reference |
||
| 574 | * http://server/NW.svc/Orders(123)/Customer |
||
| 575 | * http://server/NW.svc/Orders(123)/$links/Customer |
||
| 576 | * (c) $count |
||
| 577 | * http://server/NW.svc/Customers/$count |
||
| 578 | * (d) Primitive |
||
| 579 | * http://server/NW.svc/Customers('ALFKI')/Country |
||
| 580 | * (e) $value on primitive type |
||
| 581 | * http://server/NW.svc/Customers('ALFKI')/Country/$value |
||
| 582 | * (f) Complex |
||
| 583 | * http://server/NW.svc/Customers('ALFKI')/Address |
||
| 584 | * (g) Bag |
||
| 585 | * http://server/NW.svc/Employees(123)/Emails |
||
| 586 | * (h) MLE |
||
| 587 | * http://server/NW.svc/Employees(123)/$value |
||
| 588 | * |
||
| 589 | * ResourceType will be absent (NULL) in the following cases: |
||
| 590 | * if the last segment descriptor describes |
||
| 591 | * (a) If last segment is the only segment pointing to |
||
| 592 | * ResourceSet (single or multiple) |
||
| 593 | * http://server/NW.svc/Customers |
||
| 594 | * http://server/NW.svc/Customers('ALFKI') |
||
| 595 | * (b) Named Stream |
||
| 596 | * http://server/NW.svc/Employees(123)/Thumnail48_48 |
||
| 597 | * (c) metadata |
||
| 598 | * http://server/NW.svc/$metadata |
||
| 599 | * (d) service directory |
||
| 600 | * http://server/NW.svc |
||
| 601 | * (e) $bath |
||
| 602 | * http://server/NW.svc/$batch |
||
| 603 | * |
||
| 604 | * @return ResourceProperty|null |
||
| 605 | */ |
||
| 606 | public function getProjectedProperty() |
||
| 610 | |||
| 611 | /** |
||
| 612 | * Gets the name of the container for results. |
||
| 613 | * |
||
| 614 | * @return string|null |
||
| 615 | */ |
||
| 616 | public function getContainerName() |
||
| 620 | |||
| 621 | /** |
||
| 622 | * Sets the name of the container for results. |
||
| 623 | * |
||
| 624 | * @param string $containerName The container name. |
||
| 625 | * |
||
| 626 | * @return void |
||
| 627 | */ |
||
| 628 | public function setContainerName($containerName) |
||
| 632 | |||
| 633 | /** |
||
| 634 | * Whether thr request targets a single result or not. |
||
| 635 | * |
||
| 636 | * @return boolean |
||
| 637 | */ |
||
| 638 | public function isSingleResult() |
||
| 642 | |||
| 643 | /** |
||
| 644 | * Gets the identifier associated with the the resource path. |
||
| 645 | * |
||
| 646 | * @return string |
||
| 647 | */ |
||
| 648 | public function getIdentifier() |
||
| 652 | |||
| 653 | /** |
||
| 654 | * Gets the request uri. |
||
| 655 | * |
||
| 656 | * @return Url |
||
| 657 | */ |
||
| 658 | public function getRequestUrl() |
||
| 662 | |||
| 663 | /** |
||
| 664 | * Gets the value of $skip query option |
||
| 665 | * |
||
| 666 | * @return int|null The value of $skip query option, NULL if $skip is absent. |
||
| 667 | * |
||
| 668 | */ |
||
| 669 | public function getSkipCount() |
||
| 673 | |||
| 674 | /** |
||
| 675 | * Sets skip value |
||
| 676 | * |
||
| 677 | * @param int $skipCount The value of $skip query option. |
||
| 678 | * |
||
| 679 | * @return void |
||
| 680 | */ |
||
| 681 | public function setSkipCount($skipCount) |
||
| 685 | |||
| 686 | /** |
||
| 687 | * Gets the value of take count |
||
| 688 | * |
||
| 689 | * @return int|null The value of take, NULL if no take to be applied. |
||
| 690 | * |
||
| 691 | */ |
||
| 692 | public function getTopCount() |
||
| 696 | |||
| 697 | /** |
||
| 698 | * Sets the value of take count |
||
| 699 | * |
||
| 700 | * @param int $topCount The value of take query option |
||
| 701 | * |
||
| 702 | * @return void |
||
| 703 | */ |
||
| 704 | public function setTopCount($topCount) |
||
| 708 | |||
| 709 | /** |
||
| 710 | * Gets the value of $top query option |
||
| 711 | * |
||
| 712 | * @return int|null The value of $top query option, NULL if $top is absent. |
||
| 713 | * |
||
| 714 | */ |
||
| 715 | public function getTopOptionCount() |
||
| 719 | |||
| 720 | /** |
||
| 721 | * Sets top value |
||
| 722 | * |
||
| 723 | * @param int $topOptionCount The value of $top query option |
||
| 724 | * |
||
| 725 | * @return void |
||
| 726 | */ |
||
| 727 | public function setTopOptionCount($topOptionCount) |
||
| 731 | |||
| 732 | /** |
||
| 733 | * Gets sorting (orderby) information, this function return |
||
| 734 | * sorting information in 3 cases: |
||
| 735 | * (1) if $orderby option is specified in the request uri |
||
| 736 | * (2) if $skip or $top option is specified in the request uri |
||
| 737 | * (3) if server side paging is enabled for the resource targeted |
||
| 738 | * by the request uri. |
||
| 739 | * |
||
| 740 | * @return InternalOrderByInfo|null |
||
| 741 | */ |
||
| 742 | public function getInternalOrderByInfo() |
||
| 746 | |||
| 747 | /** |
||
| 748 | * Sets sorting (orderby) information. |
||
| 749 | * |
||
| 750 | * @param InternalOrderByInfo &$internalOrderByInfo The sorting information. |
||
| 751 | * |
||
| 752 | * @return void |
||
| 753 | */ |
||
| 754 | public function setInternalOrderByInfo(InternalOrderByInfo &$internalOrderByInfo) |
||
| 758 | |||
| 759 | /** |
||
| 760 | * Gets the parsed details for $skiptoken option. |
||
| 761 | * |
||
| 762 | * @return InternalSkipTokenInfo|null Returns parsed details of $skiptoken option, NULL if $skiptoken is absent. |
||
| 763 | * |
||
| 764 | */ |
||
| 765 | public function getInternalSkipTokenInfo() |
||
| 769 | |||
| 770 | /** |
||
| 771 | * Sets $skiptoken information. |
||
| 772 | * |
||
| 773 | * @param InternalSkipTokenInfo &$internalSkipTokenInfo The paging information. |
||
| 774 | * |
||
| 775 | * @return void |
||
| 776 | */ |
||
| 777 | public function setInternalSkipTokenInfo( |
||
| 782 | |||
| 783 | /** |
||
| 784 | * |
||
| 785 | * @return FilterInfo|null Returns parsed details of $filter option, NULL if $filter is absent. |
||
| 786 | * |
||
| 787 | */ |
||
| 788 | public function getFilterInfo() |
||
| 792 | |||
| 793 | /** |
||
| 794 | * |
||
| 795 | * @param FilterInfo $filterInfo The filter information. |
||
| 796 | * |
||
| 797 | */ |
||
| 798 | public function setFilterInfo(FilterInfo $filterInfo) |
||
| 802 | |||
| 803 | /** |
||
| 804 | * Sets $expand and $select information. |
||
| 805 | * |
||
| 806 | * @param RootProjectionNode &$rootProjectionNode Root of the projection tree. |
||
| 807 | * |
||
| 808 | * @return void |
||
| 809 | */ |
||
| 810 | public function setRootProjectionNode(RootProjectionNode &$rootProjectionNode) |
||
| 814 | |||
| 815 | /** |
||
| 816 | * Gets the root of the tree describing expand and select options, |
||
| 817 | * |
||
| 818 | * @return RootProjectionNode|null Returns parsed details of $expand |
||
| 819 | * and $select options, NULL if |
||
| 820 | * $both options are absent. |
||
| 821 | */ |
||
| 822 | public function getRootProjectionNode() |
||
| 826 | |||
| 827 | |||
| 828 | /** |
||
| 829 | * Gets the count of result set if $count or $inlinecount=allpages |
||
| 830 | * has been applied otherwise NULL |
||
| 831 | * |
||
| 832 | * @return int|null |
||
| 833 | */ |
||
| 834 | public function getCountValue() |
||
| 838 | |||
| 839 | /** |
||
| 840 | * Sets the count of result set. |
||
| 841 | * |
||
| 842 | * @param int $countValue The count value. |
||
| 843 | * |
||
| 844 | * @return void |
||
| 845 | */ |
||
| 846 | public function setCountValue($countValue) |
||
| 850 | |||
| 851 | /** |
||
| 852 | * To set the flag indicating the execution status as true. |
||
| 853 | * |
||
| 854 | * @return void |
||
| 855 | */ |
||
| 856 | public function setExecuted() |
||
| 860 | |||
| 861 | /** |
||
| 862 | * To check whether to execute the query using IDSQP. |
||
| 863 | * |
||
| 864 | * @return boolean True if query need to be executed, False otherwise. |
||
| 865 | */ |
||
| 866 | public function needExecution() |
||
| 872 | |||
| 873 | /** |
||
| 874 | * To check if the resource path is a request for link uri. |
||
| 875 | * |
||
| 876 | * @return boolean True if request is for link uri else false. |
||
| 877 | */ |
||
| 878 | public function isLinkUri() |
||
| 882 | |||
| 883 | /** |
||
| 884 | * To check if the resource path is a request for meida resource |
||
| 885 | * |
||
| 886 | * @return boolean True if request is for media resource else false. |
||
| 887 | */ |
||
| 888 | public function isMediaResource() |
||
| 892 | |||
| 893 | /** |
||
| 894 | * To check if the resource path is a request for named stream |
||
| 895 | * |
||
| 896 | * @return boolean True if request is for named stream else false. |
||
| 897 | */ |
||
| 898 | public function isNamedStream() |
||
| 902 | |||
| 903 | /** |
||
| 904 | * Get ResourceStreamInfo for the media link entry or named stream request. |
||
| 905 | * |
||
| 906 | * @return ResourceStreamInfo|null Instance of ResourceStreamInfo if the |
||
| 907 | * current request targets named stream, NULL for MLE |
||
| 908 | */ |
||
| 909 | public function getResourceStreamInfo() |
||
| 921 | |||
| 922 | /** |
||
| 923 | * Gets the resource instance targeted by the request uri. |
||
| 924 | * Note: This value will be populated after query execution only. |
||
| 925 | * |
||
| 926 | * @return mixed |
||
| 927 | */ |
||
| 928 | public function getTargetResult() |
||
| 940 | |||
| 941 | /** |
||
| 942 | * Gets the OData version the server used to generate the response. |
||
| 943 | * |
||
| 944 | * @return Version |
||
| 945 | */ |
||
| 946 | public function getResponseVersion() |
||
| 951 | |||
| 952 | /** |
||
| 953 | * Checks whether etag headers are allowed for this request. |
||
| 954 | * |
||
| 955 | * @return boolean True if ETag header (If-Match or If-NoneMatch) |
||
| 956 | * is allowed for the request, False otherwise. |
||
| 957 | */ |
||
| 958 | public function isETagHeaderAllowed() |
||
| 967 | |||
| 968 | /** |
||
| 969 | * Gets collection of known data service versions, currently 1.0, 2.0 and 3.0. |
||
| 970 | * |
||
| 971 | * @return Version[] |
||
| 972 | */ |
||
| 973 | public static function getKnownDataServiceVersions() |
||
| 985 | |||
| 986 | /** |
||
| 987 | * This function is used to perform following checking (validation) |
||
| 988 | * for capability negotiation. |
||
| 989 | * (1) Check client request's 'DataServiceVersion' header value is |
||
| 990 | * less than or equal to the minimum version required to intercept |
||
| 991 | * the response |
||
| 992 | * (2) Check client request's 'MaxDataServiceVersion' header value is |
||
| 993 | * less than or equal to the version of protocol required to generate |
||
| 994 | * the response |
||
| 995 | * (3) Check the configured maximum protocol version is less than or equal |
||
| 996 | * to the version of protocol required to generate the response |
||
| 997 | * In addition to these checking, this function is also responsible for |
||
| 998 | * initializing the properties representing 'DataServiceVersion' and |
||
| 999 | * 'MaxDataServiceVersion'. |
||
| 1000 | * |
||
| 1001 | * |
||
| 1002 | * @throws ODataException If any of the above 3 check fails. |
||
| 1003 | */ |
||
| 1004 | public function validateVersions() { |
||
| 1036 | |||
| 1037 | /** |
||
| 1038 | * Validates the given version in string format and returns the version as instance of Version |
||
| 1039 | * |
||
| 1040 | * @param string $versionHeader The DataServiceVersion or MaxDataServiceVersion header value |
||
| 1041 | * @param string $headerName The name of the header |
||
| 1042 | * |
||
| 1043 | * @return Version |
||
| 1044 | * |
||
| 1045 | * @throws ODataException If the version is malformed or not supported |
||
| 1046 | */ |
||
| 1047 | private static function parseVersionHeader($versionHeader, $headerName) |
||
| 1133 | |||
| 1134 | /** |
||
| 1135 | * Gets reference to the UriProcessor instance. |
||
| 1136 | * |
||
| 1137 | * @return UriProcessor |
||
| 1138 | */ |
||
| 1139 | public function getUriProcessor() |
||
| 1143 | |||
| 1144 | /** |
||
| 1145 | * Set reference to UriProcessor instance. |
||
| 1146 | * |
||
| 1147 | * @param UriProcessor $uriProcessor Reference to the UriProcessor |
||
| 1148 | * |
||
| 1149 | * @return void |
||
| 1150 | */ |
||
| 1151 | public function setUriProcessor(UriProcessor $uriProcessor) |
||
| 1155 | } |
||
| 1156 |
In PHP, under loose comparison (like
==, or!=, orswitchconditions), values of different types might be equal.For
stringvalues, the empty string''is a special case, in particular the following results might be unexpected: