Completed
Push — master ( c7e8d1...934444 )
by Bálint
02:50
created
src/POData/HttpProcessUtility.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
                 //the rest look like QSPs..kinda so we can do this
104 104
                 parse_str(implode("&", $candidateParts), $candidateParts);
105 105
                 if(array_key_exists('odata', $candidateParts)){
106
-                   $candidateODataValue = $candidateParts['odata'];
106
+                    $candidateODataValue = $candidateParts['odata'];
107 107
                 }
108 108
             }
109 109
 
@@ -696,7 +696,7 @@  discard block
 block discarded – undo
696 696
         return $c == ',' || $c == ' ' || $c == '\t';
697 697
     }
698 698
 
699
-	/**
699
+    /**
700 700
      * Get server key by header
701 701
      * @param string $headerName Name of header
702 702
      */
@@ -717,6 +717,6 @@  discard block
 block discarded – undo
717 717
             case 'MAXDATASERVICEVERSION':
718 718
                 return 'HTTP_' . $name;
719 719
         }
720
-		return $name;
721
-	}
720
+        return $name;
721
+    }
722 722
 }
Please login to merge, or discard this patch.
src/POData/OperationContext/Web/Illuminate/IncomingIlluminateRequest.php 1 patch
Indentation   +112 added lines, -112 removed lines patch added patch discarded remove patch
@@ -10,116 +10,116 @@
 block discarded – undo
10 10
 
11 11
 class IncomingIlluminateRequest implements IHTTPRequest
12 12
 {
13
-	/**
14
-	 * The Illuminate request
15
-	 *
16
-	 * @var Request
17
-	 */
18
-	private $request;
19
-
20
-	/**
21
-	 * The request headers
22
-	 *
23
-	 * @var array
24
-	 */
25
-	private $_headers;
26
-
27
-	/**
28
-	 * The incoming url in raw format
29
-	 *
30
-	 * @var string
31
-	 */
32
-	private $_rawUrl  = null;
33
-
34
-
35
-	/**
36
-	 * The request method (GET, POST, PUT, DELETE or MERGE)
37
-	 *
38
-	 * @var HTTPRequestMethod HttpVerb
39
-	 */
40
-	private $_method;
41
-
42
-	/**
43
-	 * The query options as key value.
44
-	 *
45
-	 * @var array(string, string);
46
-	 */
47
-	private $_queryOptions;
48
-
49
-	/**
50
-	 * A collection that represents mapping between query
51
-	 * option and its count.
52
-	 *
53
-	 * @var array(string, int)
54
-	 */
55
-	private $_queryOptionsCount;
56
-
57
-	/**
58
-	 * IncomingIlluminateRequest constructor.
59
-	 * @param Request $request
60
-	 */
61
-	public function __construct(Request $request)
62
-	{
63
-		$this->request = $request;
64
-		$this->_headers = null;
65
-		$this->_queryOptions = null;
66
-		$this->_queryOptionsCount = null;
67
-		$this->_method = new HTTPRequestMethod($this->request->getMethod());
68
-	}
69
-
70
-	/**
71
-	 * @return string RequestURI called by User with the value of QueryString
72
-	 */
73
-	public function getRawUrl()
74
-	{
75
-		$this->_rawUrl = $this->request->fullUrl();
76
-
77
-		return $this->_rawUrl;
78
-	}
79
-
80
-	/**
81
-	 * @param string $key The header name
82
-	 * @return array|null|string
83
-	 */
84
-	public function getRequestHeader($key)
85
-	{
86
-		$result = $this->request->header($key);
87
-		//Zend returns false for a missing header...POData needs a null
88
-		if($result === false || $result === ''){
89
-			return null;
90
-		}
91
-		return $result;
92
-	}
93
-
94
-	/**
95
-	 * Returns the Query String Parameters (QSPs) as an array of KEY-VALUE pairs.  If a QSP appears twice
96
-	 * it will have two entries in this array
97
-	 *
98
-	 * @return array
99
-	 */
100
-	public function getQueryParameters()
101
-	{
102
-		//TODO: the contract is more specific than this, it requires the name and values to be decoded
103
-		//not sure how to test that...
104
-		//TODO: another issue.  This may not be the right thing to return...since POData only really understands GET requests today
105
-		//Have to convert to the stranger format known to POData that deals with multiple query strings.
106
-		//this makes this request a bit non compliant as it doesn't expose duplicate keys, something POData will check for
107
-		//instead whatever parameter was last in the query string is set.  IE
108
-		//odata.svc/?$format=xml&$format=json the format will be json
109
-		$this->_queryOptions = [];
110
-		$this->_queryOptionsCount = 0;
111
-		foreach($this->request->all() as $key => $value){
112
-			$this->_queryOptions[] = [$key => $value];
113
-			$this->_queryOptionsCount++;
114
-		}
115
-		return $this->_queryOptions;
116
-	}
117
-
118
-	/**
119
-	 * @return HTTPRequestMethod
120
-	 */
121
-	public function getMethod()
122
-	{
123
-		return $this->_method;
124
-	}
13
+    /**
14
+     * The Illuminate request
15
+     *
16
+     * @var Request
17
+     */
18
+    private $request;
19
+
20
+    /**
21
+     * The request headers
22
+     *
23
+     * @var array
24
+     */
25
+    private $_headers;
26
+
27
+    /**
28
+     * The incoming url in raw format
29
+     *
30
+     * @var string
31
+     */
32
+    private $_rawUrl  = null;
33
+
34
+
35
+    /**
36
+     * The request method (GET, POST, PUT, DELETE or MERGE)
37
+     *
38
+     * @var HTTPRequestMethod HttpVerb
39
+     */
40
+    private $_method;
41
+
42
+    /**
43
+     * The query options as key value.
44
+     *
45
+     * @var array(string, string);
46
+     */
47
+    private $_queryOptions;
48
+
49
+    /**
50
+     * A collection that represents mapping between query
51
+     * option and its count.
52
+     *
53
+     * @var array(string, int)
54
+     */
55
+    private $_queryOptionsCount;
56
+
57
+    /**
58
+     * IncomingIlluminateRequest constructor.
59
+     * @param Request $request
60
+     */
61
+    public function __construct(Request $request)
62
+    {
63
+        $this->request = $request;
64
+        $this->_headers = null;
65
+        $this->_queryOptions = null;
66
+        $this->_queryOptionsCount = null;
67
+        $this->_method = new HTTPRequestMethod($this->request->getMethod());
68
+    }
69
+
70
+    /**
71
+     * @return string RequestURI called by User with the value of QueryString
72
+     */
73
+    public function getRawUrl()
74
+    {
75
+        $this->_rawUrl = $this->request->fullUrl();
76
+
77
+        return $this->_rawUrl;
78
+    }
79
+
80
+    /**
81
+     * @param string $key The header name
82
+     * @return array|null|string
83
+     */
84
+    public function getRequestHeader($key)
85
+    {
86
+        $result = $this->request->header($key);
87
+        //Zend returns false for a missing header...POData needs a null
88
+        if($result === false || $result === ''){
89
+            return null;
90
+        }
91
+        return $result;
92
+    }
93
+
94
+    /**
95
+     * Returns the Query String Parameters (QSPs) as an array of KEY-VALUE pairs.  If a QSP appears twice
96
+     * it will have two entries in this array
97
+     *
98
+     * @return array
99
+     */
100
+    public function getQueryParameters()
101
+    {
102
+        //TODO: the contract is more specific than this, it requires the name and values to be decoded
103
+        //not sure how to test that...
104
+        //TODO: another issue.  This may not be the right thing to return...since POData only really understands GET requests today
105
+        //Have to convert to the stranger format known to POData that deals with multiple query strings.
106
+        //this makes this request a bit non compliant as it doesn't expose duplicate keys, something POData will check for
107
+        //instead whatever parameter was last in the query string is set.  IE
108
+        //odata.svc/?$format=xml&$format=json the format will be json
109
+        $this->_queryOptions = [];
110
+        $this->_queryOptionsCount = 0;
111
+        foreach($this->request->all() as $key => $value){
112
+            $this->_queryOptions[] = [$key => $value];
113
+            $this->_queryOptionsCount++;
114
+        }
115
+        return $this->_queryOptions;
116
+    }
117
+
118
+    /**
119
+     * @return HTTPRequestMethod
120
+     */
121
+    public function getMethod()
122
+    {
123
+        return $this->_method;
124
+    }
125 125
 }
Please login to merge, or discard this patch.
src/POData/BaseService.php 1 patch
Indentation   +171 added lines, -171 removed lines patch added patch discarded remove patch
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
     }
100 100
 
101 101
 
102
-	//TODO: shouldn't we hide this from the interface..if we need it at all.
102
+    //TODO: shouldn't we hide this from the interface..if we need it at all.
103 103
     /**
104 104
      * Get the wrapper over developer's IQueryProvider and IMetadataProvider implementation.
105 105
      *
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
      */
108 108
     public function getProvidersWrapper()
109 109
     {
110
-          return $this->providersWrapper;
110
+            return $this->providersWrapper;
111 111
     }
112 112
 
113 113
     /**
@@ -230,33 +230,33 @@  discard block
 block discarded – undo
230 230
         }
231 231
     }
232 232
 
233
-	/**
234
-	 * @return IQueryProvider
235
-	 */
236
-	public abstract function getQueryProvider();
233
+    /**
234
+     * @return IQueryProvider
235
+     */
236
+    public abstract function getQueryProvider();
237 237
 
238
-	/**
239
-	 * @return IMetadataProvider
240
-	 */
241
-	public abstract function getMetadataProvider();
238
+    /**
239
+     * @return IMetadataProvider
240
+     */
241
+    public abstract function getMetadataProvider();
242 242
 
243
-	/**
244
-	 * @return \POData\Providers\Stream\IStreamProvider
245
-	 */
246
-	public abstract function getStreamProviderX();
243
+    /**
244
+     * @return \POData\Providers\Stream\IStreamProvider
245
+     */
246
+    public abstract function getStreamProviderX();
247 247
 
248 248
 
249
-	/** @var  ODataWriterRegistry */
250
-	private $writerRegistry;
249
+    /** @var  ODataWriterRegistry */
250
+    private $writerRegistry;
251 251
 
252
-	/**
253
-	 * Returns the ODataWriterRegistry to use when writing the response to a service document or resource request
254
-	 * @return ODataWriterRegistry
255
-	 */
256
-	public function getODataWriterRegistry()
257
-	{
258
-		return $this->writerRegistry;
259
-	}
252
+    /**
253
+     * Returns the ODataWriterRegistry to use when writing the response to a service document or resource request
254
+     * @return ODataWriterRegistry
255
+     */
256
+    public function getODataWriterRegistry()
257
+    {
258
+        return $this->writerRegistry;
259
+    }
260 260
 
261 261
 
262 262
     /**
@@ -302,32 +302,32 @@  discard block
 block discarded – undo
302 302
 
303 303
         $this->initialize($this->config);
304 304
 
305
-	    //TODO: this seems like a bad spot to do this
306
-	    $this->writerRegistry = new ODataWriterRegistry();
307
-	    $this->registerWriters();
305
+        //TODO: this seems like a bad spot to do this
306
+        $this->writerRegistry = new ODataWriterRegistry();
307
+        $this->registerWriters();
308 308
     }
309 309
 
310
-	//TODO: i don't want this to be public..but it's the only way to test it right now...
311
-	public function registerWriters()
312
-	{
313
-		$registry = $this->getODataWriterRegistry();
314
-		$serviceVersion = $this->getConfiguration()->getMaxDataServiceVersion();
315
-		$serviceURI = $this->getHost()->getAbsoluteServiceUri()->getUrlAsString();
310
+    //TODO: i don't want this to be public..but it's the only way to test it right now...
311
+    public function registerWriters()
312
+    {
313
+        $registry = $this->getODataWriterRegistry();
314
+        $serviceVersion = $this->getConfiguration()->getMaxDataServiceVersion();
315
+        $serviceURI = $this->getHost()->getAbsoluteServiceUri()->getUrlAsString();
316 316
 
317
-		//We always register the v1 stuff
318
-		$registry->register(new JsonODataV1Writer());
319
-		$registry->register(new AtomODataWriter($serviceURI));
317
+        //We always register the v1 stuff
318
+        $registry->register(new JsonODataV1Writer());
319
+        $registry->register(new AtomODataWriter($serviceURI));
320 320
 
321
-		if($serviceVersion->compare(Version::v2()) > -1){
322
-			$registry->register(new JsonODataV2Writer());
323
-		}
321
+        if($serviceVersion->compare(Version::v2()) > -1){
322
+            $registry->register(new JsonODataV2Writer());
323
+        }
324 324
 
325
-		if($serviceVersion->compare(Version::v3()) > -1){
326
-			$registry->register(new JsonLightODataWriter(JsonLightMetadataLevel::NONE(), $serviceURI));
327
-			$registry->register(new JsonLightODataWriter(JsonLightMetadataLevel::MINIMAL(), $serviceURI));
328
-			$registry->register(new JsonLightODataWriter(JsonLightMetadataLevel::FULL(), $serviceURI));
329
-		}
330
-	}
325
+        if($serviceVersion->compare(Version::v3()) > -1){
326
+            $registry->register(new JsonLightODataWriter(JsonLightMetadataLevel::NONE(), $serviceURI));
327
+            $registry->register(new JsonLightODataWriter(JsonLightMetadataLevel::MINIMAL(), $serviceURI));
328
+            $registry->register(new JsonLightODataWriter(JsonLightMetadataLevel::FULL(), $serviceURI));
329
+        }
330
+    }
331 331
 
332 332
     /**
333 333
      * Serialize the requested resource.
@@ -351,12 +351,12 @@  discard block
 block discarded – undo
351 351
 
352 352
         $responseContentType = self::getResponseContentType($request, $uriProcessor, $this);
353 353
 
354
-	    if (is_null($responseContentType) && $request->getTargetKind() != TargetKind::MEDIA_RESOURCE()) {
355
-		    //the responseContentType can ONLY be null if it's a stream (media resource) and that stream is storing null as the content type
356
-		    throw new ODataException( Messages::unsupportedMediaType(), 415 );
357
-	    }
354
+        if (is_null($responseContentType) && $request->getTargetKind() != TargetKind::MEDIA_RESOURCE()) {
355
+            //the responseContentType can ONLY be null if it's a stream (media resource) and that stream is storing null as the content type
356
+            throw new ODataException( Messages::unsupportedMediaType(), 415 );
357
+        }
358 358
 
359
-	    $odataModelInstance = null;
359
+        $odataModelInstance = null;
360 360
         $hasResponseBody = true;
361 361
         // Execution required at this point if request target to any resource other than
362 362
         //
@@ -407,7 +407,7 @@  discard block
 block discarded – undo
407 407
                     // In the query 'Orders(1245)/$links/Customer', the targeted
408 408
                     // Customer might be null
409 409
                     if (is_null($result)) {
410
-						throw ODataException::createResourceNotFoundError(
410
+                        throw ODataException::createResourceNotFoundError(
411 411
                             $request->getIdentifier()
412 412
                         );
413 413
                     }
@@ -417,7 +417,7 @@  discard block
 block discarded – undo
417 417
                     if (!is_null($this->_serviceHost->getRequestIfMatch())
418 418
                         && !is_null($this->_serviceHost->getRequestIfNoneMatch())
419 419
                     ) {
420
-						throw ODataException::createBadRequestError(
420
+                        throw ODataException::createBadRequestError(
421 421
                             Messages::bothIfMatchAndIfNoneMatchHeaderSpecified()
422 422
                         );
423 423
                     }
@@ -453,22 +453,22 @@  discard block
 block discarded – undo
453 453
                     }
454 454
                 } else if ($requestTargetKind == TargetKind::COMPLEX_OBJECT()) {
455 455
 
456
-	                $odataModelInstance = $objectModelSerializer->writeTopLevelComplexObject(
456
+                    $odataModelInstance = $objectModelSerializer->writeTopLevelComplexObject(
457 457
                         $result,
458 458
                         $request->getProjectedProperty()->getName(),
459
-	                    $request->getTargetResourceType()
460
-	                );
459
+                        $request->getTargetResourceType()
460
+                    );
461 461
                 } else if ($requestTargetKind == TargetKind::BAG()) {
462 462
                     $odataModelInstance = $objectModelSerializer->writeTopLevelBagObject(
463 463
                         $result,
464 464
                         $request->getProjectedProperty()->getName(),
465
-	                    $request->getTargetResourceType(),
465
+                        $request->getTargetResourceType(),
466 466
                         $odataModelInstance
467 467
                     );
468 468
                 } else if ($requestTargetKind == TargetKind::PRIMITIVE()) {
469 469
                     $odataModelInstance = $objectModelSerializer->writeTopLevelPrimitive(
470 470
                         $result,
471
-	                    $request->getProjectedProperty(),
471
+                        $request->getProjectedProperty(),
472 472
                         $odataModelInstance
473 473
                     );
474 474
                 } else if ($requestTargetKind == TargetKind::PRIMITIVE_VALUE()) {
@@ -486,10 +486,10 @@  discard block
 block discarded – undo
486 486
         //Note: Response content type can be null for named stream
487 487
         if ($hasResponseBody && !is_null($responseContentType)) {
488 488
             if ($request->getTargetKind() != TargetKind::MEDIA_RESOURCE() && $responseContentType != MimeTypes::MIME_APPLICATION_OCTETSTREAM) {
489
-	            //append charset for everything except:
490
-	            //stream resources as they have their own content type
491
-	            //binary properties (they content type will be App Octet for those...is this a good way? we could also decide based upon the projected property
492
-	            //
489
+                //append charset for everything except:
490
+                //stream resources as they have their own content type
491
+                //binary properties (they content type will be App Octet for those...is this a good way? we could also decide based upon the projected property
492
+                //
493 493
                 $responseContentType .= ';charset=utf-8';
494 494
             }
495 495
         }
@@ -517,7 +517,7 @@  discard block
 block discarded – undo
517 517
      * @throws ODataException, HttpHeaderFailure
518 518
      */
519 519
     public static function getResponseContentType(
520
-	    RequestDescription $request,
520
+        RequestDescription $request,
521 521
         UriProcessor $uriProcessor,
522 522
         IService $service
523 523
     ) {
@@ -525,12 +525,12 @@  discard block
 block discarded – undo
525 525
         // The Accept request-header field specifies media types which are acceptable for the response
526 526
 
527 527
         $host = $service->getHost();
528
-	    $requestAcceptText = $host->getRequestAccept();
528
+        $requestAcceptText = $host->getRequestAccept();
529 529
         $requestVersion = $request->getResponseVersion();
530 530
 
531
-	    //if the $format header is present it overrides the accepts header
532
-	    $format = $host->getQueryStringItem(ODataConstants::HTTPQUERY_STRING_FORMAT);
533
-	    if(!is_null($format)){
531
+        //if the $format header is present it overrides the accepts header
532
+        $format = $host->getQueryStringItem(ODataConstants::HTTPQUERY_STRING_FORMAT);
533
+        if(!is_null($format)){
534 534
 
535 535
             //There's a strange edge case..if application/json is supplied and it's V3
536 536
             if($format == MimeTypes::MIME_APPLICATION_JSON && $requestVersion == Version::v3()){
@@ -539,128 +539,128 @@  discard block
 block discarded – undo
539 539
                 $format = MimeTypes::MIME_APPLICATION_JSON_MINIMAL_META;
540 540
             }
541 541
 
542
-		    $requestAcceptText = ServiceHost::translateFormatToMime($requestVersion, $format);
543
-	    }
542
+            $requestAcceptText = ServiceHost::translateFormatToMime($requestVersion, $format);
543
+        }
544 544
 
545 545
 
546 546
 
547 547
 
548
-	    //The response format can be dictated by the target resource kind. IE a $value will be different then expected
549
-	    //getTargetKind doesn't deal with link resources directly and this can change things
550
-	    $targetKind = $request->isLinkUri() ? TargetKind::LINK() : $request->getTargetKind();
548
+        //The response format can be dictated by the target resource kind. IE a $value will be different then expected
549
+        //getTargetKind doesn't deal with link resources directly and this can change things
550
+        $targetKind = $request->isLinkUri() ? TargetKind::LINK() : $request->getTargetKind();
551 551
 
552
-	    switch($targetKind){
553
-		    case TargetKind::METADATA():
554
-			    return HttpProcessUtility::selectMimeType(
555
-				    $requestAcceptText,
556
-				    array(MimeTypes::MIME_APPLICATION_XML)
557
-			    );
552
+        switch($targetKind){
553
+            case TargetKind::METADATA():
554
+                return HttpProcessUtility::selectMimeType(
555
+                    $requestAcceptText,
556
+                    array(MimeTypes::MIME_APPLICATION_XML)
557
+                );
558 558
 
559
-		    case TargetKind::SERVICE_DIRECTORY():
560
-			    return HttpProcessUtility::selectMimeType(
561
-				    $requestAcceptText,
562
-				    array(
563
-					    MimeTypes::MIME_APPLICATION_XML,
564
-					    MimeTypes::MIME_APPLICATION_ATOMSERVICE,
565
-					    MimeTypes::MIME_APPLICATION_JSON,
559
+            case TargetKind::SERVICE_DIRECTORY():
560
+                return HttpProcessUtility::selectMimeType(
561
+                    $requestAcceptText,
562
+                    array(
563
+                        MimeTypes::MIME_APPLICATION_XML,
564
+                        MimeTypes::MIME_APPLICATION_ATOMSERVICE,
565
+                        MimeTypes::MIME_APPLICATION_JSON,
566 566
                         MimeTypes::MIME_APPLICATION_JSON_FULL_META,
567 567
                         MimeTypes::MIME_APPLICATION_JSON_NO_META,
568 568
                         MimeTypes::MIME_APPLICATION_JSON_MINIMAL_META,
569
-					    MimeTypes::MIME_APPLICATION_JSON_VERBOSE,
569
+                        MimeTypes::MIME_APPLICATION_JSON_VERBOSE,
570 570
 
571 571
                     )
572
-			    );
573
-
574
-		    case TargetKind::PRIMITIVE_VALUE():
575
-			    $supportedResponseMimeTypes = array(MimeTypes::MIME_TEXTPLAIN);
576
-
577
-			    if ($request->getIdentifier() != '$count') {
578
-				    $projectedProperty = $request->getProjectedProperty();
579
-				    self::assert(
580
-					    !is_null($projectedProperty),
581
-					    '!is_null($projectedProperty)'
582
-				    );
583
-				    $type = $projectedProperty->getInstanceType();
584
-				    self::assert(
585
-					    !is_null($type) && $type instanceof IType,
586
-					    '!is_null($type) && $type instanceof IType'
587
-				    );
588
-				    if ($type instanceof Binary) {
589
-					    $supportedResponseMimeTypes = array(MimeTypes::MIME_APPLICATION_OCTETSTREAM);
590
-				    }
591
-			    }
592
-
593
-			    return HttpProcessUtility::selectMimeType(
594
-				    $requestAcceptText,
595
-				    $supportedResponseMimeTypes
596
-			    );
597
-
598
-		    case TargetKind::PRIMITIVE():
599
-		    case TargetKind::COMPLEX_OBJECT():
600
-		    case TargetKind::BAG():
601
-		    case TargetKind::LINK():
602
-			    return HttpProcessUtility::selectMimeType(
603
-				    $requestAcceptText,
604
-				    array(
605
-					    MimeTypes::MIME_APPLICATION_XML,
606
-					    MimeTypes::MIME_TEXTXML,
607
-					    MimeTypes::MIME_APPLICATION_JSON,
572
+                );
573
+
574
+            case TargetKind::PRIMITIVE_VALUE():
575
+                $supportedResponseMimeTypes = array(MimeTypes::MIME_TEXTPLAIN);
576
+
577
+                if ($request->getIdentifier() != '$count') {
578
+                    $projectedProperty = $request->getProjectedProperty();
579
+                    self::assert(
580
+                        !is_null($projectedProperty),
581
+                        '!is_null($projectedProperty)'
582
+                    );
583
+                    $type = $projectedProperty->getInstanceType();
584
+                    self::assert(
585
+                        !is_null($type) && $type instanceof IType,
586
+                        '!is_null($type) && $type instanceof IType'
587
+                    );
588
+                    if ($type instanceof Binary) {
589
+                        $supportedResponseMimeTypes = array(MimeTypes::MIME_APPLICATION_OCTETSTREAM);
590
+                    }
591
+                }
592
+
593
+                return HttpProcessUtility::selectMimeType(
594
+                    $requestAcceptText,
595
+                    $supportedResponseMimeTypes
596
+                );
597
+
598
+            case TargetKind::PRIMITIVE():
599
+            case TargetKind::COMPLEX_OBJECT():
600
+            case TargetKind::BAG():
601
+            case TargetKind::LINK():
602
+                return HttpProcessUtility::selectMimeType(
603
+                    $requestAcceptText,
604
+                    array(
605
+                        MimeTypes::MIME_APPLICATION_XML,
606
+                        MimeTypes::MIME_TEXTXML,
607
+                        MimeTypes::MIME_APPLICATION_JSON,
608 608
                         MimeTypes::MIME_APPLICATION_JSON_FULL_META,
609 609
                         MimeTypes::MIME_APPLICATION_JSON_NO_META,
610 610
                         MimeTypes::MIME_APPLICATION_JSON_MINIMAL_META,
611
-					    MimeTypes::MIME_APPLICATION_JSON_VERBOSE,
612
-				    )
613
-			    );
611
+                        MimeTypes::MIME_APPLICATION_JSON_VERBOSE,
612
+                    )
613
+                );
614 614
 
615 615
             case TargetKind::BATCH():
616
-		    case TargetKind::RESOURCE():
617
-			    return HttpProcessUtility::selectMimeType(
618
-				    $requestAcceptText,
619
-				    array(
620
-					    MimeTypes::MIME_APPLICATION_ATOM,
621
-					    MimeTypes::MIME_APPLICATION_JSON,
616
+            case TargetKind::RESOURCE():
617
+                return HttpProcessUtility::selectMimeType(
618
+                    $requestAcceptText,
619
+                    array(
620
+                        MimeTypes::MIME_APPLICATION_ATOM,
621
+                        MimeTypes::MIME_APPLICATION_JSON,
622 622
                         MimeTypes::MIME_APPLICATION_JSON_FULL_META,
623 623
                         MimeTypes::MIME_APPLICATION_JSON_NO_META,
624 624
                         MimeTypes::MIME_APPLICATION_JSON_MINIMAL_META,
625
-					    MimeTypes::MIME_APPLICATION_JSON_VERBOSE,
626
-				    )
627
-			    );
628
-
629
-		    case TargetKind::MEDIA_RESOURCE():
630
-			    if (!$request->isNamedStream() && !$request->getTargetResourceType()->isMediaLinkEntry()){
631
-					throw ODataException::createBadRequestError(
632
-					    Messages::badRequestInvalidUriForMediaResource(
633
-						    $host->getAbsoluteRequestUri()->getUrlAsString()
634
-					    )
635
-				    );
636
-			    }
637
-
638
-			    $uriProcessor->execute();
639
-			    $request->setExecuted();
640
-			    // DSSW::getStreamContentType can throw error in 2 cases
641
-			    // 1. If the required stream implementation not found
642
-			    // 2. If IDSSP::getStreamContentType returns NULL for MLE
643
-			    $responseContentType = $service->getStreamProviderWrapper()
644
-				    ->getStreamContentType(
645
-					    $request->getTargetResult(),
646
-					    $request->getResourceStreamInfo()
647
-				    );
648
-
649
-
650
-			    // Note StreamWrapper::getStreamContentType can return NULL if the requested named stream has not
651
-			    // yet been uploaded. But for an MLE if IDSSP::getStreamContentType returns NULL then StreamWrapper will throw error
652
-			    if (!is_null($responseContentType)) {
653
-				    $responseContentType = HttpProcessUtility::selectMimeType(
654
-					    $requestAcceptText,
655
-					    array($responseContentType)
656
-				    );
657
-			    }
658
-
659
-			    return $responseContentType;
660
-	    }
661
-
662
-
663
-	    //If we got here, we just don't know what it is...
625
+                        MimeTypes::MIME_APPLICATION_JSON_VERBOSE,
626
+                    )
627
+                );
628
+
629
+            case TargetKind::MEDIA_RESOURCE():
630
+                if (!$request->isNamedStream() && !$request->getTargetResourceType()->isMediaLinkEntry()){
631
+                    throw ODataException::createBadRequestError(
632
+                        Messages::badRequestInvalidUriForMediaResource(
633
+                            $host->getAbsoluteRequestUri()->getUrlAsString()
634
+                        )
635
+                    );
636
+                }
637
+
638
+                $uriProcessor->execute();
639
+                $request->setExecuted();
640
+                // DSSW::getStreamContentType can throw error in 2 cases
641
+                // 1. If the required stream implementation not found
642
+                // 2. If IDSSP::getStreamContentType returns NULL for MLE
643
+                $responseContentType = $service->getStreamProviderWrapper()
644
+                    ->getStreamContentType(
645
+                        $request->getTargetResult(),
646
+                        $request->getResourceStreamInfo()
647
+                    );
648
+
649
+
650
+                // Note StreamWrapper::getStreamContentType can return NULL if the requested named stream has not
651
+                // yet been uploaded. But for an MLE if IDSSP::getStreamContentType returns NULL then StreamWrapper will throw error
652
+                if (!is_null($responseContentType)) {
653
+                    $responseContentType = HttpProcessUtility::selectMimeType(
654
+                        $requestAcceptText,
655
+                        array($responseContentType)
656
+                    );
657
+                }
658
+
659
+                return $responseContentType;
660
+        }
661
+
662
+
663
+        //If we got here, we just don't know what it is...
664 664
         throw new ODataException( Messages::unsupportedMediaType(), 415 );
665 665
 
666 666
     }
@@ -702,7 +702,7 @@  discard block
 block discarded – undo
702 702
         if ($this->config->getValidateETagHeader() && !$resourceType->hasETagProperties()) {
703 703
             if (!is_null($ifMatch) || !is_null($ifNoneMatch)) {
704 704
                 // No eTag properties but request has eTag headers, bad request
705
-				throw ODataException::createBadRequestError(
705
+                throw ODataException::createBadRequestError(
706 706
                     Messages::noETagPropertiesForType()
707 707
                 );
708 708
             }
@@ -789,7 +789,7 @@  discard block
 block discarded – undo
789 789
             $value = null;
790 790
             try {
791 791
 
792
-	            //TODO #88...also this seems like dupe work
792
+                //TODO #88...also this seems like dupe work
793 793
                 $reflectionProperty  = new \ReflectionProperty($entryObject, $eTagProperty->getName() );
794 794
                 $value = $reflectionProperty->getValue($entryObject);
795 795
             } catch (\ReflectionException $reflectionException) {
Please login to merge, or discard this patch.
src/POData/UriProcessor/RequestDescription.php 1 patch
Indentation   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -78,8 +78,8 @@  discard block
 block discarded – undo
78 78
      */
79 79
     private $requiredMinRequestVersion;
80 80
 
81
-	/** @var Version */
82
-	private $maxServiceVersion;
81
+    /** @var Version */
82
+    private $maxServiceVersion;
83 83
 
84 84
     /**
85 85
      * Collection of known data service versions.
@@ -117,12 +117,12 @@  discard block
 block discarded – undo
117 117
     private $_containerName;
118 118
 
119 119
 
120
-	/**
121
-	 * The count option specified in the request.
122
-	 *
123
-	 * @var QueryType
124
-	 */
125
-	public $queryType;
120
+    /**
121
+     * The count option specified in the request.
122
+     *
123
+     * @var QueryType
124
+     */
125
+    public $queryType;
126 126
 
127 127
     /**
128 128
      * Number of segments.
@@ -226,47 +226,47 @@  discard block
 block discarded – undo
226 226
      * Reference to the service
227 227
      * @var IService
228 228
      */
229
-     private $_service;
229
+        private $_service;
230 230
 
231 231
     /**
232 232
      * The parts of a multipart request
233 233
      * @var array
234 234
      */
235
-     private $_parts;
235
+        private $_parts;
236 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
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 243
      * @param string $dataType
244
-	 */
245
-	public function __construct($segmentDescriptors, Url $requestUri, Version $serviceMaxVersion, $requestVersion, $maxRequestVersion, $dataType = null, IService $service = null)
244
+     */
245
+    public function __construct($segmentDescriptors, Url $requestUri, Version $serviceMaxVersion, $requestVersion, $maxRequestVersion, $dataType = null, IService $service = null)
246 246
     {
247 247
         $this->segments = $segmentDescriptors;
248 248
         $this->_segmentCount = count($this->segments);
249 249
         $this->requestUrl = $requestUri;
250 250
         $this->lastSegment = $segmentDescriptors[$this->_segmentCount - 1];
251
-	    $this->queryType = QueryType::ENTITIES();
251
+        $this->queryType = QueryType::ENTITIES();
252 252
         $this->_service = $service;
253 253
         $this->_parts = array();
254 254
 
255 255
         //we use this for validation checks down in validateVersions...but maybe we should check that outside of this object...
256 256
         $this->maxServiceVersion = $serviceMaxVersion;
257 257
 
258
-	    //Per OData 1 & 2 spec we must return the smallest size
259
-	    //We start at 1.0 and move it up as features are requested
258
+        //Per OData 1 & 2 spec we must return the smallest size
259
+        //We start at 1.0 and move it up as features are requested
260 260
         $this->requiredMinResponseVersion = clone Version::v1();
261 261
         $this->requiredMinRequestVersion = clone Version::v1();
262 262
 
263 263
 
264
-	    //see http://www.odata.org/documentation/odata-v2-documentation/overview/#ProtocolVersioning
265
-	    //if requestVersion isn't there, use Service Max Version
266
-	    $this->requestVersion = is_null($requestVersion) ? $serviceMaxVersion : self::parseVersionHeader($requestVersion, ODataConstants::ODATAVERSIONHEADER);
264
+        //see http://www.odata.org/documentation/odata-v2-documentation/overview/#ProtocolVersioning
265
+        //if requestVersion isn't there, use Service Max Version
266
+        $this->requestVersion = is_null($requestVersion) ? $serviceMaxVersion : self::parseVersionHeader($requestVersion, ODataConstants::ODATAVERSIONHEADER);
267 267
 
268
-	    //if max version isn't there, use the request version
269
-	    $this->requestMaxVersion = is_null($maxRequestVersion) ? $this->requestVersion : self::parseVersionHeader($maxRequestVersion, ODataConstants::ODATAMAXVERSIONHEADER);
268
+        //if max version isn't there, use the request version
269
+        $this->requestMaxVersion = is_null($maxRequestVersion) ? $this->requestVersion : self::parseVersionHeader($maxRequestVersion, ODataConstants::ODATAMAXVERSIONHEADER);
270 270
 
271 271
         //if it's OData v3..things change a bit
272 272
         if($this->maxServiceVersion == Version::v3()){
@@ -404,7 +404,7 @@  discard block
 block discarded – undo
404 404
     public function raiseMinVersionRequirement($major, $minor) {
405 405
         if($this->requiredMinRequestVersion->raiseVersion($major, $minor))
406 406
         {
407
-	        $this->validateVersions();
407
+            $this->validateVersions();
408 408
         }
409 409
     }
410 410
 
@@ -419,7 +419,7 @@  discard block
 block discarded – undo
419 419
      */
420 420
     public function raiseResponseVersion($major, $minor) {
421 421
         if($this->requiredMinResponseVersion->raiseVersion($major, $minor)){
422
-	        $this->validateVersions();
422
+            $this->validateVersions();
423 423
         }
424 424
 
425 425
     }
@@ -947,7 +947,7 @@  discard block
 block discarded – undo
947 947
     public function getResponseVersion()
948 948
     {
949 949
 
950
-	    return $this->requiredMinResponseVersion;
950
+        return $this->requiredMinResponseVersion;
951 951
     }
952 952
 
953 953
     /**
@@ -975,7 +975,7 @@  discard block
 block discarded – undo
975 975
     {
976 976
         if (is_null(self::$_knownDataServiceVersions)) {
977 977
             self::$_knownDataServiceVersions = array(
978
-	            new Version(1, 0),
978
+                new Version(1, 0),
979 979
                 new Version(2, 0),
980 980
                 new Version(3, 0)
981 981
             );
@@ -1004,32 +1004,32 @@  discard block
 block discarded – undo
1004 1004
      */
1005 1005
     public function validateVersions() {
1006 1006
 
1007
-	    //If the request version is below the minimum version required by supplied request arguments..throw an exception
1007
+        //If the request version is below the minimum version required by supplied request arguments..throw an exception
1008 1008
         if ($this->requestVersion->compare($this->requiredMinRequestVersion) < 0) {
1009
-			throw ODataException::createBadRequestError(
1009
+            throw ODataException::createBadRequestError(
1010 1010
                 Messages::requestVersionTooLow(
1011
-	                $this->requestVersion->toString(),
1012
-	                $this->requiredMinRequestVersion->toString()
1011
+                    $this->requestVersion->toString(),
1012
+                    $this->requiredMinRequestVersion->toString()
1013 1013
                 )
1014 1014
             );
1015 1015
         }
1016 1016
 
1017
-	    //If the requested max version is below the version required to fulfill the response...throw an exception
1017
+        //If the requested max version is below the version required to fulfill the response...throw an exception
1018 1018
         if ($this->requestMaxVersion->compare($this->requiredMinResponseVersion) < 0) {
1019
-			throw ODataException::createBadRequestError(
1019
+            throw ODataException::createBadRequestError(
1020 1020
                 Messages::requestVersionTooLow(
1021
-	                $this->requestMaxVersion->toString(),
1022
-	                $this->requiredMinResponseVersion->toString()
1021
+                    $this->requestMaxVersion->toString(),
1022
+                    $this->requiredMinResponseVersion->toString()
1023 1023
                 )
1024 1024
             );
1025 1025
         }
1026 1026
 
1027 1027
         //If the max version supported by the service is below the version required to fulfill the response..throw an exception
1028 1028
         if ($this->maxServiceVersion->compare($this->requiredMinResponseVersion) < 0) {
1029
-			throw ODataException::createBadRequestError(
1029
+            throw ODataException::createBadRequestError(
1030 1030
                 Messages::requestVersionIsBiggerThanProtocolVersion(
1031
-	                $this->requiredMinResponseVersion->toString(),
1032
-	                $this->maxServiceVersion->toString()
1031
+                    $this->requiredMinResponseVersion->toString(),
1032
+                    $this->maxServiceVersion->toString()
1033 1033
                 )
1034 1034
             );
1035 1035
         }
@@ -1060,9 +1060,9 @@  discard block
 block discarded – undo
1060 1060
         for ($i = 0; $i < $libNameIndex; $i++) {
1061 1061
             if ($versionHeader[$i] == '.') {
1062 1062
 
1063
-	            //Throw an exception if we find more than 1 dot
1064
-	            if ($dotIndex != -1) {
1065
-					throw ODataException::createBadRequestError(
1063
+                //Throw an exception if we find more than 1 dot
1064
+                if ($dotIndex != -1) {
1065
+                    throw ODataException::createBadRequestError(
1066 1066
                         Messages::requestDescriptionInvalidVersionHeader(
1067 1067
                             $versionHeader,
1068 1068
                             $headerName
@@ -1072,7 +1072,7 @@  discard block
 block discarded – undo
1072 1072
 
1073 1073
                 $dotIndex = $i;
1074 1074
             } else if ($versionHeader[$i] < '0' || $versionHeader[$i] > '9') {
1075
-				throw ODataException::createBadRequestError(
1075
+                throw ODataException::createBadRequestError(
1076 1076
                     Messages::requestDescriptionInvalidVersionHeader(
1077 1077
                         $versionHeader,
1078 1078
                         $headerName
@@ -1082,14 +1082,14 @@  discard block
 block discarded – undo
1082 1082
         }
1083 1083
 
1084 1084
 
1085
-	    $major = intval(substr($versionHeader, 0, $dotIndex));
1086
-	    $minor = 0;
1085
+        $major = intval(substr($versionHeader, 0, $dotIndex));
1086
+        $minor = 0;
1087 1087
 
1088
-	   //Apparently the . is optional
1088
+        //Apparently the . is optional
1089 1089
         if ($dotIndex != -1) {
1090 1090
             if ($dotIndex == 0) {
1091
-	            //If it starts with a ., throw an exception
1092
-				throw ODataException::createBadRequestError(
1091
+                //If it starts with a ., throw an exception
1092
+                throw ODataException::createBadRequestError(
1093 1093
                     Messages::requestDescriptionInvalidVersionHeader(
1094 1094
                         $versionHeader,
1095 1095
                         $headerName
@@ -1102,8 +1102,8 @@  discard block
 block discarded – undo
1102 1102
 
1103 1103
         $version = new Version($major, $minor);
1104 1104
 
1105
-	    //TODO: move this somewhere...
1106
-	    /*
1105
+        //TODO: move this somewhere...
1106
+        /*
1107 1107
         $isSupportedVersion = false;
1108 1108
         foreach (self::getKnownDataServiceVersions() as $version1) {
1109 1109
             if ($version->compare($version1) == 0) {
Please login to merge, or discard this patch.