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