Completed
Push — master ( 7e191b...5fbcda )
by Nikolay
03:00
created
services/NorthWind/NorthWindMetadata.php 2 patches
Unused Use Statements   -9 removed lines patch added patch discarded remove patch
@@ -1,17 +1,8 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 use POData\Providers\Metadata\ResourceStreamInfo;
4
-use POData\Providers\Metadata\ResourceAssociationSetEnd;
5
-use POData\Providers\Metadata\ResourceAssociationSet;
6
-use POData\Common\NotImplementedException;
7 4
 use POData\Providers\Metadata\Type\EdmPrimitiveType;
8
-use POData\Providers\Metadata\ResourceSet;
9
-use POData\Providers\Metadata\ResourcePropertyKind;
10
-use POData\Providers\Metadata\ResourceProperty;
11
-use POData\Providers\Metadata\ResourceTypeKind;
12
-use POData\Providers\Metadata\ResourceType;
13 5
 use POData\Common\InvalidOperationException;
14
-use POData\Providers\Metadata\IMetadataProvider;
15 6
 require_once 'POData\Providers\Metadata\IDataServiceMetadataProvider.php';
16 7
 use POData\Providers\Metadata\SimpleMetadataProvider;
17 8
 //Begin Resource Classes
Please login to merge, or discard this patch.
Indentation   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -117,49 +117,49 @@
 block discarded – undo
117 117
 class Employee
118 118
 {
119 119
     //Key Edm.Int32
120
-     public $EmployeeID;
121
-     //Edm.String
122
-     public $FirstName;
123
-     //Edm.String
124
-     public $LastName;
125
-     //Edm.String
126
-     public $Title;
127
-     //Edm.String
128
-     public $TitleOfCourtesy;
129
-     //Edm.DateTime
130
-     public $BirthDate;
131
-     //Edm.DateTime
132
-     public $HireDate;
133
-     //Edm.String
134
-     public $Address;
135
-     //Edm.String
136
-     public $City;
137
-     //Edm.String
138
-     public $Region;
139
-     //Edm.String
140
-     public $PostalCode;
141
-     //Edm.String
142
-     public $Country;
143
-     //Edm.String
144
-     public $HomePhone;
145
-     //Edm.String
146
-     public $Extension;
147
-     //Edm.String
148
-     public $Notes;
149
-     //Bag of strings
150
-     public $Emails;
151
-     //Edm.Int32
152
-     public $ReportsTo;
153
-     //Edm.Binary
154
-     public $Photo;
155
-     //Edm.String
156
-     public $PhotoPath;
157
-     //Navigation Property to associated instance of Employee instance 
158
-     //representing manager (ResourceReference)
159
-     //public $Manager; 
160
-     //Navigation Property to associated instance of Employee instances 
161
-     //representing subordinates (ResourceSetReference)
162
-     //public $Subordinates;
120
+        public $EmployeeID;
121
+        //Edm.String
122
+        public $FirstName;
123
+        //Edm.String
124
+        public $LastName;
125
+        //Edm.String
126
+        public $Title;
127
+        //Edm.String
128
+        public $TitleOfCourtesy;
129
+        //Edm.DateTime
130
+        public $BirthDate;
131
+        //Edm.DateTime
132
+        public $HireDate;
133
+        //Edm.String
134
+        public $Address;
135
+        //Edm.String
136
+        public $City;
137
+        //Edm.String
138
+        public $Region;
139
+        //Edm.String
140
+        public $PostalCode;
141
+        //Edm.String
142
+        public $Country;
143
+        //Edm.String
144
+        public $HomePhone;
145
+        //Edm.String
146
+        public $Extension;
147
+        //Edm.String
148
+        public $Notes;
149
+        //Bag of strings
150
+        public $Emails;
151
+        //Edm.Int32
152
+        public $ReportsTo;
153
+        //Edm.Binary
154
+        public $Photo;
155
+        //Edm.String
156
+        public $PhotoPath;
157
+        //Navigation Property to associated instance of Employee instance 
158
+        //representing manager (ResourceReference)
159
+        //public $Manager; 
160
+        //Navigation Property to associated instance of Employee instances 
161
+        //representing subordinates (ResourceSetReference)
162
+        //public $Subordinates;
163 163
 }
164 164
 //End Resource Classes
165 165
 
Please login to merge, or discard this patch.
services/WordPress/WordPressDataService.php 2 patches
Unused Use Statements   -5 removed lines patch added patch discarded remove patch
@@ -8,11 +8,6 @@
 block discarded – undo
8 8
 use POData\Configuration\ProtocolVersion;
9 9
 use POData\Configuration\ServiceConfiguration;
10 10
 use POData\BaseService;
11
-use POData\OperationContext\ServiceHost;
12
-use POData\Common\ODataException;
13
-use POData\Common\ODataConstants;
14
-use POData\Common\Messages;
15
-use POData\UriProcessor\UriProcessor;
16 11
 require_once 'WordPressMetadata.php';
17 12
 require_once 'WordPressQueryProvider.php';
18 13
 require_once 'WordPressDSExpressionProvider.php';
Please login to merge, or discard this patch.
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -53,13 +53,13 @@
 block discarded – undo
53 53
      */
54 54
     public function getService($serviceType)
55 55
     {
56
-      if(($serviceType === 'IMetadataProvider') ||
56
+        if(($serviceType === 'IMetadataProvider') ||
57 57
         ($serviceType === 'IQueryProvider') ||
58 58
         ($serviceType === 'IStreamProvider')) {
59 59
         if (is_null($this->_wordPressExpressionProvider)) {
60 60
         $this->_wordPressExpressionProvider = new WordPressDSExpressionProvider();    			
61 61
         }    	
62
-      }
62
+        }
63 63
         if ($serviceType === 'IMetadataProvider') {
64 64
             if (is_null($this->_wordPressMetadata)) {
65 65
                 $this->_wordPressMetadata = CreateWordPressMetadata::create();
Please login to merge, or discard this patch.
services/WordPress/WordPressDSExpressionProvider.php 2 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -2,7 +2,6 @@
 block discarded – undo
2 2
 
3 3
 use POData\UriProcessor\QueryProcessor\ExpressionParser\Expressions\ExpressionType;
4 4
 use POData\Providers\Metadata\Type\IType;
5
-use POData\Common\NotImplementedException;
6 5
 use POData\Common\ODataConstants;
7 6
 use POData\Providers\Expression\IExpressionProvider;
8 7
 use POData\Providers\Metadata\ResourceType;
Please login to merge, or discard this patch.
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
      */
50 50
     public function __construct()
51 51
     {
52
-      $this->_entityMapping = CreateWordPressMetadata::getEntityMapping();
52
+        $this->_entityMapping = CreateWordPressMetadata::getEntityMapping();
53 53
     }
54 54
 
55 55
     /**
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
      */
71 71
     public function setResourceType(ResourceType $resourceType)
72 72
     {
73
-      $this->_resourceType = $resourceType;
73
+        $this->_resourceType = $resourceType;
74 74
     }
75 75
 
76 76
     /**
@@ -223,11 +223,11 @@  discard block
 block discarded – undo
223 223
         $entityTypeName = $this->_resourceType->getName();
224 224
         $propertyName = $parent->getResourceProperty()->getName();
225 225
         if (is_array($this->_entityMapping)) {
226
-          if (array_key_exists($entityTypeName, $this->_entityMapping)) {
226
+            if (array_key_exists($entityTypeName, $this->_entityMapping)) {
227 227
             if (array_key_exists($propertyName, $this->_entityMapping[$entityTypeName])) {
228
-              return $this->_entityMapping[$entityTypeName][$propertyName];
228
+                return $this->_entityMapping[$entityTypeName][$propertyName];
229
+            }
229 230
             }
230
-          }
231 231
         }
232 232
      
233 233
         return $propertyName;
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
             return "LENGTH($params[0])";
284 284
             break;
285 285
         case ODataConstants::GUIDFUN_EQUAL:
286
-        	return "STRCMP($params[0], $params[1])";
286
+            return "STRCMP($params[0], $params[1])";
287 287
             break;
288 288
         case ODataConstants::DATETIME_COMPARE:
289 289
             return "DATETIMECMP($params[0]; $params[1])";
@@ -338,14 +338,14 @@  discard block
 block discarded – undo
338 338
      */
339 339
     private function _prepareBinaryExpression($operator, $left, $right)
340 340
     {
341
-      // Special handling for DATETIMECMP
342
-      if (!substr_compare($left, "DATETIMECMP", 0, 11)) {
341
+        // Special handling for DATETIMECMP
342
+        if (!substr_compare($left, "DATETIMECMP", 0, 11)) {
343 343
         $str = explode(';', $left, 2);
344 344
         $str[0] = str_replace('DATETIMECMP', '', $str[0]);
345 345
         return self::OPEN_BRAKET
346
-          . $str[0] . ' ' . $operator
347
-          . ' ' . $str[1] . self::CLOSE_BRACKET;
348
-      }
346
+            . $str[0] . ' ' . $operator
347
+            . ' ' . $str[1] . self::CLOSE_BRACKET;
348
+        }
349 349
 
350 350
         return 
351 351
             self::OPEN_BRAKET 
Please login to merge, or discard this patch.
services/WordPress/WordPressMetadata.php 2 patches
Unused Use Statements   -11 removed lines patch added patch discarded remove patch
@@ -1,20 +1,9 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-use POData\Providers\Metadata\ResourceStreamInfo;
4
-use POData\Providers\Metadata\ResourceAssociationSetEnd;
5
-use POData\Providers\Metadata\ResourceAssociationSet;
6
-use POData\Common\NotImplementedException;
7 3
 use POData\Providers\Metadata\Type\EdmPrimitiveType;
8
-use POData\Providers\Metadata\ResourceSet;
9
-use POData\Providers\Metadata\ResourcePropertyKind;
10
-use POData\Providers\Metadata\ResourceProperty;
11
-use POData\Providers\Metadata\ResourceTypeKind;
12
-use POData\Providers\Metadata\ResourceType;
13 4
 use POData\Common\InvalidOperationException;
14
-use POData\Providers\Metadata\IMetadataProvider;
15 5
 require_once 'POData\Providers\Metadata\IDataServiceMetadataProvider.php';
16 6
 use POData\Providers\Metadata\SimpleMetadataProvider;
17
-use POData\Providers\Metadata\MetadataMapping;
18 7
 
19 8
 //Begin Resource Classes
20 9
 
Please login to merge, or discard this patch.
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -178,11 +178,11 @@  discard block
 block discarded – undo
178 178
 class CreateWordPressMetadata
179 179
 {
180 180
 
181
-	/**
182
-	 * Array holding the mapping between the entity properties and coulmns.
183
-	 * 
184
-	 * @var array
185
-	 */
181
+    /**
182
+     * Array holding the mapping between the entity properties and coulmns.
183
+     * 
184
+     * @var array
185
+     */
186 186
     private static $_entityMapping = array();
187 187
 
188 188
     /**
@@ -295,8 +295,8 @@  discard block
 block discarded – undo
295 295
      * @return array(string, array(string, string))
296 296
      */
297 297
     public static function getEntityMapping() {
298
-      if (!is_null(self::$_entityMapping))
299
-      {
298
+        if (!is_null(self::$_entityMapping))
299
+        {
300 300
         self::$_entityMapping = array (
301 301
             'Post' => array (
302 302
                 '$MappedTable$' => 'wp_posts',
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
                 'Type' => 'post_type',
323 323
                 'MimeType' => 'post_mime_type',
324 324
                 'CommentCount' => 'comment_count'
325
-              ),
325
+                ),
326 326
           
327 327
             'Tag' => array (
328 328
                 '$MappedTable$' => 'wp_terms',
@@ -369,9 +369,9 @@  discard block
 block discarded – undo
369 369
                 'Status' => 'user_status',
370 370
                 'DisplayName' => 'display_name'
371 371
             )
372
-          );
373
-      }
372
+            );
373
+        }
374 374
       
375
-      return self::$_entityMapping;
375
+        return self::$_entityMapping;
376 376
     }
377 377
 }
Please login to merge, or discard this patch.
src/POData/BaseService.php 2 patches
Unused Use Statements   -3 removed lines patch added patch discarded remove patch
@@ -5,7 +5,6 @@  discard block
 block discarded – undo
5 5
 use POData\Common\MimeTypes;
6 6
 use POData\Common\Version;
7 7
 use POData\OperationContext\HTTPRequestMethod;
8
-use POData\Providers\Metadata\ResourceTypeKind;
9 8
 use POData\Common\ErrorHandler;
10 9
 use POData\Common\Messages;
11 10
 use POData\Common\ODataException;
@@ -30,11 +29,9 @@  discard block
 block discarded – undo
30 29
 use POData\Writers\Json\JsonODataV1Writer;
31 30
 use POData\Writers\Json\JsonODataV2Writer;
32 31
 use POData\Writers\ResponseWriter;
33
-
34 32
 use POData\Providers\Query\IQueryProvider;
35 33
 use POData\Providers\Metadata\IMetadataProvider;
36 34
 use POData\OperationContext\IOperationContext;
37
-
38 35
 use POData\Writers\ODataWriterRegistry;
39 36
 
40 37
 /**
Please login to merge, or discard this patch.
Indentation   +172 added lines, -172 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
     /**
@@ -228,33 +228,33 @@  discard block
 block discarded – undo
228 228
         }
229 229
     }
230 230
 
231
-	/**
232
-	 * @return IQueryProvider
233
-	 */
234
-	public abstract function getQueryProvider();
231
+    /**
232
+     * @return IQueryProvider
233
+     */
234
+    public abstract function getQueryProvider();
235 235
 
236
-	/**
237
-	 * @return IMetadataProvider
238
-	 */
239
-	public abstract function getMetadataProvider();
236
+    /**
237
+     * @return IMetadataProvider
238
+     */
239
+    public abstract function getMetadataProvider();
240 240
 
241
-	/**
242
-	 * @return \POData\Providers\Stream\IStreamProvider
243
-	 */
244
-	public abstract function getStreamProviderX();
241
+    /**
242
+     * @return \POData\Providers\Stream\IStreamProvider
243
+     */
244
+    public abstract function getStreamProviderX();
245 245
 
246 246
 
247
-	/** @var  ODataWriterRegistry */
248
-	private $writerRegistry;
247
+    /** @var  ODataWriterRegistry */
248
+    private $writerRegistry;
249 249
 
250
-	/**
251
-	 * Returns the ODataWriterRegistry to use when writing the response to a service document or resource request
252
-	 * @return ODataWriterRegistry
253
-	 */
254
-	public function getODataWriterRegistry()
255
-	{
256
-		return $this->writerRegistry;
257
-	}
250
+    /**
251
+     * Returns the ODataWriterRegistry to use when writing the response to a service document or resource request
252
+     * @return ODataWriterRegistry
253
+     */
254
+    public function getODataWriterRegistry()
255
+    {
256
+        return $this->writerRegistry;
257
+    }
258 258
 
259 259
 
260 260
     /**
@@ -300,32 +300,32 @@  discard block
 block discarded – undo
300 300
         
301 301
         $this->initialize($this->config);
302 302
 
303
-	    //TODO: this seems like a bad spot to do this
304
-	    $this->writerRegistry = new ODataWriterRegistry();
305
-	    $this->registerWriters();
303
+        //TODO: this seems like a bad spot to do this
304
+        $this->writerRegistry = new ODataWriterRegistry();
305
+        $this->registerWriters();
306 306
     }
307 307
 
308
-	//TODO: i don't want this to be public..but it's the only way to test it right now...
309
-	public function registerWriters()
310
-	{
311
-		$registry = $this->getODataWriterRegistry();
312
-		$serviceVersion = $this->getConfiguration()->getMaxDataServiceVersion();
313
-		$serviceURI = $this->getHost()->getAbsoluteServiceUri()->getUrlAsString();
308
+    //TODO: i don't want this to be public..but it's the only way to test it right now...
309
+    public function registerWriters()
310
+    {
311
+        $registry = $this->getODataWriterRegistry();
312
+        $serviceVersion = $this->getConfiguration()->getMaxDataServiceVersion();
313
+        $serviceURI = $this->getHost()->getAbsoluteServiceUri()->getUrlAsString();
314 314
 
315
-		//We always register the v1 stuff
316
-		$registry->register(new JsonODataV1Writer());
317
-		$registry->register(new AtomODataWriter($serviceURI));
315
+        //We always register the v1 stuff
316
+        $registry->register(new JsonODataV1Writer());
317
+        $registry->register(new AtomODataWriter($serviceURI));
318 318
 
319
-		if($serviceVersion->compare(Version::v2()) > -1){
320
-			$registry->register(new JsonODataV2Writer());
321
-		}
319
+        if($serviceVersion->compare(Version::v2()) > -1){
320
+            $registry->register(new JsonODataV2Writer());
321
+        }
322 322
 
323
-		if($serviceVersion->compare(Version::v3()) > -1){
324
-			$registry->register(new JsonLightODataWriter(JsonLightMetadataLevel::NONE(), $serviceURI));
325
-			$registry->register(new JsonLightODataWriter(JsonLightMetadataLevel::MINIMAL(), $serviceURI));
326
-			$registry->register(new JsonLightODataWriter(JsonLightMetadataLevel::FULL(), $serviceURI));
327
-		}
328
-	}
323
+        if($serviceVersion->compare(Version::v3()) > -1){
324
+            $registry->register(new JsonLightODataWriter(JsonLightMetadataLevel::NONE(), $serviceURI));
325
+            $registry->register(new JsonLightODataWriter(JsonLightMetadataLevel::MINIMAL(), $serviceURI));
326
+            $registry->register(new JsonLightODataWriter(JsonLightMetadataLevel::FULL(), $serviceURI));
327
+        }
328
+    }
329 329
 
330 330
     /**
331 331
      * Serialize the requested resource.
@@ -349,12 +349,12 @@  discard block
 block discarded – undo
349 349
 
350 350
         $responseContentType = self::getResponseContentType($request, $uriProcessor, $this);
351 351
 
352
-	    if (is_null($responseContentType) && $request->getTargetKind() != TargetKind::MEDIA_RESOURCE()) {
353
-		    //the responseContentType can ONLY be null if it's a stream (media resource) and that stream is storing null as the content type
354
-		    throw new ODataException( Messages::unsupportedMediaType(), 415 );
355
-	    }
352
+        if (is_null($responseContentType) && $request->getTargetKind() != TargetKind::MEDIA_RESOURCE()) {
353
+            //the responseContentType can ONLY be null if it's a stream (media resource) and that stream is storing null as the content type
354
+            throw new ODataException( Messages::unsupportedMediaType(), 415 );
355
+        }
356 356
 
357
-	    $odataModelInstance = null;
357
+        $odataModelInstance = null;
358 358
         $hasResponseBody = true;
359 359
         // Execution required at this point if request target to any resource other than
360 360
         //
@@ -395,7 +395,7 @@  discard block
 block discarded – undo
395 395
                     // In the query 'Orders(1245)/$links/Customer', the targeted
396 396
                     // Customer might be null
397 397
                     if (is_null($result)) {
398
-						throw ODataException::createResourceNotFoundError(
398
+                        throw ODataException::createResourceNotFoundError(
399 399
                             $request->getIdentifier()
400 400
                         );
401 401
                     }
@@ -405,7 +405,7 @@  discard block
 block discarded – undo
405 405
                     if (!is_null($this->_serviceHost->getRequestIfMatch())
406 406
                         && !is_null($this->_serviceHost->getRequestIfNoneMatch())
407 407
                     ) {
408
-						throw ODataException::createBadRequestError(
408
+                        throw ODataException::createBadRequestError(
409 409
                             Messages::bothIfMatchAndIfNoneMatchHeaderSpecified()
410 410
                         );
411 411
                     }
@@ -441,22 +441,22 @@  discard block
 block discarded – undo
441 441
                     }
442 442
                 } else if ($requestTargetKind == TargetKind::COMPLEX_OBJECT()) {
443 443
 
444
-	                $odataModelInstance = $objectModelSerializer->writeTopLevelComplexObject(
444
+                    $odataModelInstance = $objectModelSerializer->writeTopLevelComplexObject(
445 445
                         $result, 
446 446
                         $request->getProjectedProperty()->getName(),
447
-	                    $request->getTargetResourceType()
448
-	                );
447
+                        $request->getTargetResourceType()
448
+                    );
449 449
                 } else if ($requestTargetKind == TargetKind::BAG()) {
450 450
                     $odataModelInstance = $objectModelSerializer->writeTopLevelBagObject(
451 451
                         $result, 
452 452
                         $request->getProjectedProperty()->getName(),
453
-	                    $request->getTargetResourceType(),
453
+                        $request->getTargetResourceType(),
454 454
                         $odataModelInstance
455 455
                     );
456 456
                 } else if ($requestTargetKind == TargetKind::PRIMITIVE()) {
457 457
                     $odataModelInstance = $objectModelSerializer->writeTopLevelPrimitive(
458 458
                         $result,
459
-	                    $request->getProjectedProperty(),
459
+                        $request->getProjectedProperty(),
460 460
                         $odataModelInstance
461 461
                     );
462 462
                 } else if ($requestTargetKind == TargetKind::PRIMITIVE_VALUE()) {
@@ -474,10 +474,10 @@  discard block
 block discarded – undo
474 474
         //Note: Response content type can be null for named stream
475 475
         if ($hasResponseBody && !is_null($responseContentType)) {
476 476
             if ($request->getTargetKind() != TargetKind::MEDIA_RESOURCE() && $responseContentType != MimeTypes::MIME_APPLICATION_OCTETSTREAM) {
477
-	            //append charset for everything except:
478
-	            //stream resources as they have their own content type
479
-	            //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
480
-	            //
477
+                //append charset for everything except:
478
+                //stream resources as they have their own content type
479
+                //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
480
+                //
481 481
                 $responseContentType .= ';charset=utf-8';
482 482
             }
483 483
         }
@@ -505,7 +505,7 @@  discard block
 block discarded – undo
505 505
      * @throws ODataException, HttpHeaderFailure
506 506
      */
507 507
     public static function getResponseContentType(
508
-	    RequestDescription $request,
508
+        RequestDescription $request,
509 509
         UriProcessor $uriProcessor,
510 510
         IService $service
511 511
     ) {
@@ -513,12 +513,12 @@  discard block
 block discarded – undo
513 513
         // The Accept request-header field specifies media types which are acceptable for the response
514 514
 
515 515
         $host = $service->getHost();
516
-	    $requestAcceptText = $host->getRequestAccept();
516
+        $requestAcceptText = $host->getRequestAccept();
517 517
         $requestVersion = $request->getResponseVersion();
518 518
 
519
-	    //if the $format header is present it overrides the accepts header
520
-	    $format = $host->getQueryStringItem(ODataConstants::HTTPQUERY_STRING_FORMAT);
521
-	    if(!is_null($format)){
519
+        //if the $format header is present it overrides the accepts header
520
+        $format = $host->getQueryStringItem(ODataConstants::HTTPQUERY_STRING_FORMAT);
521
+        if(!is_null($format)){
522 522
 
523 523
             //There's a strange edge case..if application/json is supplied and it's V3
524 524
             if($format == MimeTypes::MIME_APPLICATION_JSON && $requestVersion == Version::v3()){
@@ -527,127 +527,127 @@  discard block
 block discarded – undo
527 527
                 $format = MimeTypes::MIME_APPLICATION_JSON_MINIMAL_META;
528 528
             }
529 529
 
530
-		    $requestAcceptText = ServiceHost::translateFormatToMime($requestVersion, $format);
531
-	    }
530
+            $requestAcceptText = ServiceHost::translateFormatToMime($requestVersion, $format);
531
+        }
532 532
 
533 533
 
534 534
 
535 535
 
536
-	    //The response format can be dictated by the target resource kind. IE a $value will be different then expected
537
-	    //getTargetKind doesn't deal with link resources directly and this can change things
538
-	    $targetKind = $request->isLinkUri() ? TargetKind::LINK() : $request->getTargetKind();
536
+        //The response format can be dictated by the target resource kind. IE a $value will be different then expected
537
+        //getTargetKind doesn't deal with link resources directly and this can change things
538
+        $targetKind = $request->isLinkUri() ? TargetKind::LINK() : $request->getTargetKind();
539 539
 
540
-	    switch($targetKind){
541
-		    case TargetKind::METADATA():
542
-			    return HttpProcessUtility::selectMimeType(
543
-				    $requestAcceptText,
544
-				    array(MimeTypes::MIME_APPLICATION_XML)
545
-			    );
540
+        switch($targetKind){
541
+            case TargetKind::METADATA():
542
+                return HttpProcessUtility::selectMimeType(
543
+                    $requestAcceptText,
544
+                    array(MimeTypes::MIME_APPLICATION_XML)
545
+                );
546 546
 
547
-		    case TargetKind::SERVICE_DIRECTORY():
548
-			    return HttpProcessUtility::selectMimeType(
549
-				    $requestAcceptText,
550
-				    array(
551
-					    MimeTypes::MIME_APPLICATION_XML,
552
-					    MimeTypes::MIME_APPLICATION_ATOMSERVICE,
553
-					    MimeTypes::MIME_APPLICATION_JSON,
547
+            case TargetKind::SERVICE_DIRECTORY():
548
+                return HttpProcessUtility::selectMimeType(
549
+                    $requestAcceptText,
550
+                    array(
551
+                        MimeTypes::MIME_APPLICATION_XML,
552
+                        MimeTypes::MIME_APPLICATION_ATOMSERVICE,
553
+                        MimeTypes::MIME_APPLICATION_JSON,
554 554
                         MimeTypes::MIME_APPLICATION_JSON_FULL_META,
555 555
                         MimeTypes::MIME_APPLICATION_JSON_NO_META,
556 556
                         MimeTypes::MIME_APPLICATION_JSON_MINIMAL_META,
557
-					    MimeTypes::MIME_APPLICATION_JSON_VERBOSE,
557
+                        MimeTypes::MIME_APPLICATION_JSON_VERBOSE,
558 558
 
559 559
                     )
560
-			    );
561
-
562
-		    case TargetKind::PRIMITIVE_VALUE():
563
-			    $supportedResponseMimeTypes = array(MimeTypes::MIME_TEXTPLAIN);
564
-
565
-			    if ($request->getIdentifier() != '$count') {
566
-				    $projectedProperty = $request->getProjectedProperty();
567
-				    self::assert(
568
-					    !is_null($projectedProperty),
569
-					    '!is_null($projectedProperty)'
570
-				    );
571
-				    $type = $projectedProperty->getInstanceType();
572
-				    self::assert(
573
-					    !is_null($type) && $type instanceof IType,
574
-					    '!is_null($type) && $type instanceof IType'
575
-				    );
576
-				    if ($type instanceof Binary) {
577
-					    $supportedResponseMimeTypes = array(MimeTypes::MIME_APPLICATION_OCTETSTREAM);
578
-				    }
579
-			    }
580
-
581
-			    return HttpProcessUtility::selectMimeType(
582
-				    $requestAcceptText,
583
-				    $supportedResponseMimeTypes
584
-			    );
585
-
586
-		    case TargetKind::PRIMITIVE():
587
-		    case TargetKind::COMPLEX_OBJECT():
588
-		    case TargetKind::BAG():
589
-		    case TargetKind::LINK():
590
-			    return HttpProcessUtility::selectMimeType(
591
-				    $requestAcceptText,
592
-				    array(
593
-					    MimeTypes::MIME_APPLICATION_XML,
594
-					    MimeTypes::MIME_TEXTXML,
595
-					    MimeTypes::MIME_APPLICATION_JSON,
560
+                );
561
+
562
+            case TargetKind::PRIMITIVE_VALUE():
563
+                $supportedResponseMimeTypes = array(MimeTypes::MIME_TEXTPLAIN);
564
+
565
+                if ($request->getIdentifier() != '$count') {
566
+                    $projectedProperty = $request->getProjectedProperty();
567
+                    self::assert(
568
+                        !is_null($projectedProperty),
569
+                        '!is_null($projectedProperty)'
570
+                    );
571
+                    $type = $projectedProperty->getInstanceType();
572
+                    self::assert(
573
+                        !is_null($type) && $type instanceof IType,
574
+                        '!is_null($type) && $type instanceof IType'
575
+                    );
576
+                    if ($type instanceof Binary) {
577
+                        $supportedResponseMimeTypes = array(MimeTypes::MIME_APPLICATION_OCTETSTREAM);
578
+                    }
579
+                }
580
+
581
+                return HttpProcessUtility::selectMimeType(
582
+                    $requestAcceptText,
583
+                    $supportedResponseMimeTypes
584
+                );
585
+
586
+            case TargetKind::PRIMITIVE():
587
+            case TargetKind::COMPLEX_OBJECT():
588
+            case TargetKind::BAG():
589
+            case TargetKind::LINK():
590
+                return HttpProcessUtility::selectMimeType(
591
+                    $requestAcceptText,
592
+                    array(
593
+                        MimeTypes::MIME_APPLICATION_XML,
594
+                        MimeTypes::MIME_TEXTXML,
595
+                        MimeTypes::MIME_APPLICATION_JSON,
596 596
                         MimeTypes::MIME_APPLICATION_JSON_FULL_META,
597 597
                         MimeTypes::MIME_APPLICATION_JSON_NO_META,
598 598
                         MimeTypes::MIME_APPLICATION_JSON_MINIMAL_META,
599
-					    MimeTypes::MIME_APPLICATION_JSON_VERBOSE,
600
-				    )
601
-			    );
602
-
603
-		    case TargetKind::RESOURCE():
604
-			    return HttpProcessUtility::selectMimeType(
605
-				    $requestAcceptText,
606
-				    array(
607
-					    MimeTypes::MIME_APPLICATION_ATOM,
608
-					    MimeTypes::MIME_APPLICATION_JSON,
599
+                        MimeTypes::MIME_APPLICATION_JSON_VERBOSE,
600
+                    )
601
+                );
602
+
603
+            case TargetKind::RESOURCE():
604
+                return HttpProcessUtility::selectMimeType(
605
+                    $requestAcceptText,
606
+                    array(
607
+                        MimeTypes::MIME_APPLICATION_ATOM,
608
+                        MimeTypes::MIME_APPLICATION_JSON,
609 609
                         MimeTypes::MIME_APPLICATION_JSON_FULL_META,
610 610
                         MimeTypes::MIME_APPLICATION_JSON_NO_META,
611 611
                         MimeTypes::MIME_APPLICATION_JSON_MINIMAL_META,
612
-					    MimeTypes::MIME_APPLICATION_JSON_VERBOSE,
613
-				    )
614
-			    );
615
-
616
-		    case TargetKind::MEDIA_RESOURCE():
617
-			    if (!$request->isNamedStream() && !$request->getTargetResourceType()->isMediaLinkEntry()){
618
-					throw ODataException::createBadRequestError(
619
-					    Messages::badRequestInvalidUriForMediaResource(
620
-						    $host->getAbsoluteRequestUri()->getUrlAsString()
621
-					    )
622
-				    );
623
-			    }
624
-
625
-			    $uriProcessor->execute();
626
-			    $request->setExecuted();
627
-			    // DSSW::getStreamContentType can throw error in 2 cases
628
-			    // 1. If the required stream implementation not found
629
-			    // 2. If IDSSP::getStreamContentType returns NULL for MLE
630
-			    $responseContentType = $service->getStreamProviderWrapper()
631
-				    ->getStreamContentType(
632
-					    $request->getTargetResult(),
633
-					    $request->getResourceStreamInfo()
634
-				    );
635
-
636
-
637
-			    // Note StreamWrapper::getStreamContentType can return NULL if the requested named stream has not
638
-			    // yet been uploaded. But for an MLE if IDSSP::getStreamContentType returns NULL then StreamWrapper will throw error
639
-			    if (!is_null($responseContentType)) {
640
-				    $responseContentType = HttpProcessUtility::selectMimeType(
641
-					    $requestAcceptText,
642
-					    array($responseContentType)
643
-				    );
644
-			    }
645
-
646
-			    return $responseContentType;
647
-	    }
648
-
649
-
650
-	    //If we got here, we just don't know what it is...
612
+                        MimeTypes::MIME_APPLICATION_JSON_VERBOSE,
613
+                    )
614
+                );
615
+
616
+            case TargetKind::MEDIA_RESOURCE():
617
+                if (!$request->isNamedStream() && !$request->getTargetResourceType()->isMediaLinkEntry()){
618
+                    throw ODataException::createBadRequestError(
619
+                        Messages::badRequestInvalidUriForMediaResource(
620
+                            $host->getAbsoluteRequestUri()->getUrlAsString()
621
+                        )
622
+                    );
623
+                }
624
+
625
+                $uriProcessor->execute();
626
+                $request->setExecuted();
627
+                // DSSW::getStreamContentType can throw error in 2 cases
628
+                // 1. If the required stream implementation not found
629
+                // 2. If IDSSP::getStreamContentType returns NULL for MLE
630
+                $responseContentType = $service->getStreamProviderWrapper()
631
+                    ->getStreamContentType(
632
+                        $request->getTargetResult(),
633
+                        $request->getResourceStreamInfo()
634
+                    );
635
+
636
+
637
+                // Note StreamWrapper::getStreamContentType can return NULL if the requested named stream has not
638
+                // yet been uploaded. But for an MLE if IDSSP::getStreamContentType returns NULL then StreamWrapper will throw error
639
+                if (!is_null($responseContentType)) {
640
+                    $responseContentType = HttpProcessUtility::selectMimeType(
641
+                        $requestAcceptText,
642
+                        array($responseContentType)
643
+                    );
644
+                }
645
+
646
+                return $responseContentType;
647
+        }
648
+
649
+
650
+        //If we got here, we just don't know what it is...
651 651
         throw new ODataException( Messages::unsupportedMediaType(), 415 );
652 652
 
653 653
     }
@@ -689,7 +689,7 @@  discard block
 block discarded – undo
689 689
         if ($this->config->getValidateETagHeader() && !$resourceType->hasETagProperties()) {
690 690
             if (!is_null($ifMatch) || !is_null($ifNoneMatch)) {
691 691
                 // No eTag properties but request has eTag headers, bad request
692
-				throw ODataException::createBadRequestError(
692
+                throw ODataException::createBadRequestError(
693 693
                     Messages::noETagPropertiesForType()
694 694
                 );
695 695
             }
@@ -776,7 +776,7 @@  discard block
 block discarded – undo
776 776
             $value = null; 
777 777
             try {
778 778
 
779
-	            //TODO #88...also this seems like dupe work
779
+                //TODO #88...also this seems like dupe work
780 780
                 $reflectionProperty  = new \ReflectionProperty($entryObject, $eTagProperty->getName() );
781 781
                 $value = $reflectionProperty->getValue($entryObject);
782 782
             } catch (\ReflectionException $reflectionException) {
Please login to merge, or discard this patch.
src/POData/Common/ErrorHandler.php 2 patches
Unused Use Statements   -2 removed lines patch added patch discarded remove patch
@@ -4,9 +4,7 @@
 block discarded – undo
4 4
 
5 5
 
6 6
 use POData\Writers\Json\JsonODataV2Writer;
7
-
8 7
 use POData\Writers\Atom\AtomODataWriter;
9
-use POData\BaseService;
10 8
 use POData\HttpProcessUtility;
11 9
 use POData\IService;
12 10
 
Please login to merge, or discard this patch.
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -32,8 +32,8 @@
 block discarded – undo
32 32
             $responseContentType = HttpProcessUtility::selectMimeType(
33 33
                 $acceptTypesText, 
34 34
                 array(
35
-	                MimeTypes::MIME_APPLICATION_XML,
36
-	                MimeTypes::MIME_APPLICATION_JSON
35
+                    MimeTypes::MIME_APPLICATION_XML,
36
+                    MimeTypes::MIME_APPLICATION_JSON
37 37
                 )
38 38
             );
39 39
         } catch (HttpHeaderFailure $exception) {
Please login to merge, or discard this patch.
src/POData/ObjectModel/ObjectModelSerializerBase.php 2 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -5,7 +5,6 @@
 block discarded – undo
5 5
 
6 6
 use POData\Common\ODataConstants;
7 7
 use POData\IService;
8
-use POData\Providers\ProvidersWrapper;
9 8
 use POData\Providers\Metadata\ResourceSetWrapper;
10 9
 use POData\Providers\Metadata\ResourceProperty;
11 10
 use POData\Providers\Metadata\ResourceTypeKind;
Please login to merge, or discard this patch.
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -159,9 +159,9 @@  discard block
 block discarded – undo
159 159
     protected function getPropertyValue($entity, ResourceType $resourceType, ResourceProperty $resourceProperty)
160 160
     {
161 161
         try {
162
-	        //Is this slow?  See #88
163
-			$reflectionProperty = new \ReflectionProperty($entity, $resourceProperty->getName());
164
-	        return $reflectionProperty->getValue($entity);
162
+            //Is this slow?  See #88
163
+            $reflectionProperty = new \ReflectionProperty($entity, $resourceProperty->getName());
164
+            return $reflectionProperty->getValue($entity);
165 165
         } catch (\ReflectionException $reflectionException) {
166 166
             throw ODataException::createInternalServerError(
167 167
                 Messages::objectModelSerializerFailedToAccessProperty(
@@ -558,7 +558,7 @@  discard block
 block discarded – undo
558 558
             //presence of $top option affect next link for root container
559 559
             $topValueCount = $this->request->getTopOptionCount();
560 560
             if (!is_null($topValueCount) && ($topValueCount <= $pageSize)) {
561
-                 return false;
561
+                    return false;
562 562
             }            
563 563
         }
564 564
 
Please login to merge, or discard this patch.
src/POData/OperationContext/ServiceHost.php 2 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -8,7 +8,6 @@
 block discarded – undo
8 8
 use POData\Common\Url;
9 9
 use POData\Common\UrlFormatException;
10 10
 use POData\Common\ODataException;
11
-use POData\Common\InvalidOperationException;
12 11
 use POData\OperationContext\Web\WebOperationContext;
13 12
 use POData\OperationContext\IOperationContext;
14 13
 use POData\Common\Version;
Please login to merge, or discard this patch.
Indentation   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -80,16 +80,16 @@  discard block
 block discarded – undo
80 80
         return $this->_operationContext;
81 81
     }
82 82
 
83
-	/**
84
-	 * @param IOperationContext $context the OperationContext implementation to use.  If null the WebOperationContext
85
-	 * will be used.  Defaults to null.
86
-	 */
87
-	public function __construct(IOperationContext $context = null)
83
+    /**
84
+     * @param IOperationContext $context the OperationContext implementation to use.  If null the WebOperationContext
85
+     * will be used.  Defaults to null.
86
+     */
87
+    public function __construct(IOperationContext $context = null)
88 88
     {
89 89
         if(is_null($context)){
90
-	        $this->_operationContext = new WebOperationContext();
90
+            $this->_operationContext = new WebOperationContext();
91 91
         } else {
92
-	        $this->_operationContext = $context;
92
+            $this->_operationContext = $context;
93 93
         }
94 94
 
95 95
         // getAbsoluteRequestUri can throw UrlFormatException 
@@ -99,13 +99,13 @@  discard block
 block discarded – undo
99 99
     }
100 100
 
101 101
     /**
102
-      * Gets the absolute request Uri as Url instance
103
-      * Note: This method will be called first time from constructor.
104
-      * 
105
-      * @throws ODataException if AbsoluteRequestUri is not a valid URI
106
-      * 
107
-      * @return Url
108
-      */
102
+     * Gets the absolute request Uri as Url instance
103
+     * Note: This method will be called first time from constructor.
104
+     * 
105
+     * @throws ODataException if AbsoluteRequestUri is not a valid URI
106
+     * 
107
+     * @return Url
108
+     */
109 109
     public function getAbsoluteRequestUri()
110 110
     {
111 111
         if (is_null($this->_absoluteRequestUri)) {
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
             try {
115 115
                 new Url($this->_absoluteRequestUriAsString);
116 116
             } catch (UrlFormatException $exception) {
117
-				throw ODataException::createBadRequestError($exception->getMessage());
117
+                throw ODataException::createBadRequestError($exception->getMessage());
118 118
             }
119 119
 
120 120
             $queryStartIndex = strpos($this->_absoluteRequestUriAsString, '?');
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
                 $j = count($segments) - 1;
195 195
                 $k = $i;
196 196
                 if ($j > $i) {
197
-					throw ODataException::createBadRequestError(
197
+                    throw ODataException::createBadRequestError(
198 198
                         Messages::hostRequestUriIsNotBasedOnRelativeUriInConfig(
199 199
                             $this->_absoluteRequestUriAsString,
200 200
                             $serviceUri
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
                 }
208 208
 
209 209
                 if ($j != -1) {
210
-					throw ODataException::createBadRequestError(
210
+                    throw ODataException::createBadRequestError(
211 211
                         Messages::hostRequestUriIsNotBasedOnRelativeUriInConfig(
212 212
                             $this->_absoluteRequestUriAsString,
213 213
                             $serviceUri
@@ -280,13 +280,13 @@  discard block
 block discarded – undo
280 280
                 if (!empty($optionValue)) {
281 281
                     if ($optionValue[0] == '$') {
282 282
                         if ($this->_isODataQueryOption($optionValue)) {
283
-							throw ODataException::createBadRequestError(
283
+                            throw ODataException::createBadRequestError(
284 284
                                 Messages::hostODataQueryOptionFoundWithoutValue(
285 285
                                     $optionValue
286 286
                                 )
287 287
                             );
288 288
                         } else {
289
-							throw ODataException::createBadRequestError(
289
+                            throw ODataException::createBadRequestError(
290 290
                                 Messages::hostNonODataOptionBeginsWithSystemCharacter(
291 291
                                     $optionValue
292 292
                                 )
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
             } else {
298 298
                 if ($optionName[0] == '$') {
299 299
                     if (!$this->_isODataQueryOption($optionName)) {
300
-						throw ODataException::createBadRequestError(
300
+                        throw ODataException::createBadRequestError(
301 301
                             Messages::hostNonODataOptionBeginsWithSystemCharacter(
302 302
                                 $optionName
303 303
                             )
@@ -305,7 +305,7 @@  discard block
 block discarded – undo
305 305
                     }
306 306
 
307 307
                     if (array_search($optionName, $namesFound) !== false) {
308
-						throw ODataException::createBadRequestError(
308
+                        throw ODataException::createBadRequestError(
309 309
                             Messages::hostODataQueryOptionCannotBeSpecifiedMoreThanOnce(
310 310
                                 $optionName
311 311
                             )
@@ -313,7 +313,7 @@  discard block
 block discarded – undo
313 313
                     }
314 314
                     
315 315
                     if (empty($optionValue) && $optionValue !== '0') {
316
-						throw ODataException::createBadRequestError(
316
+                        throw ODataException::createBadRequestError(
317 317
                             Messages::hostODataQueryOptionFoundWithoutValue(
318 318
                                 $optionName
319 319
                             )
@@ -629,29 +629,29 @@  discard block
 block discarded – undo
629 629
             ->outgoingResponse()->addHeader($headerName, $headerValue);
630 630
     }
631 631
 
632
-	/**
633
-	 * Translates the short $format forms into the full mime type forms
634
-	 * @param Version $responseVersion the version scheme to interpret the short form with
635
-	 * @param string $format the short $format form
636
-	 * @return string the full mime type corresponding to the short format form for the given version
637
-	 */
638
-	public static function translateFormatToMime(Version $responseVersion, $format){
632
+    /**
633
+     * Translates the short $format forms into the full mime type forms
634
+     * @param Version $responseVersion the version scheme to interpret the short form with
635
+     * @param string $format the short $format form
636
+     * @return string the full mime type corresponding to the short format form for the given version
637
+     */
638
+    public static function translateFormatToMime(Version $responseVersion, $format){
639 639
         //TODO: should the version switches be off of the requestVersion, not the response version? see #91
640 640
 
641 641
         switch($format) {
642 642
 
643
-	        case ODataConstants::FORMAT_XML:
644
-		        $format = MimeTypes::MIME_APPLICATION_XML;
645
-		        break;
643
+            case ODataConstants::FORMAT_XML:
644
+                $format = MimeTypes::MIME_APPLICATION_XML;
645
+                break;
646 646
 
647 647
             case ODataConstants::FORMAT_ATOM:
648
-	            $format = MimeTypes::MIME_APPLICATION_ATOM ;
649
-		        break;
648
+                $format = MimeTypes::MIME_APPLICATION_ATOM ;
649
+                break;
650 650
 
651 651
             case ODataConstants::FORMAT_VERBOSE_JSON:
652 652
                 if($responseVersion == Version::v3()){
653
-	                //only translatable in 3.0 systems
654
-	                $format = MimeTypes::MIME_APPLICATION_JSON_VERBOSE;
653
+                    //only translatable in 3.0 systems
654
+                    $format = MimeTypes::MIME_APPLICATION_JSON_VERBOSE;
655 655
                 }
656 656
                 break;
657 657
 
@@ -659,13 +659,13 @@  discard block
 block discarded – undo
659 659
                 if($responseVersion == Version::v3()){
660 660
                     $format = MimeTypes::MIME_APPLICATION_JSON_MINIMAL_META;
661 661
                 } else{
662
-	                $format = MimeTypes::MIME_APPLICATION_JSON;
662
+                    $format = MimeTypes::MIME_APPLICATION_JSON;
663 663
                 }
664
-		        break;
664
+                break;
665 665
 
666 666
         }
667 667
 
668
-	    return $format . ';q=1.0';
668
+        return $format . ';q=1.0';
669 669
     }
670 670
 
671 671
 
Please login to merge, or discard this patch.
src/POData/OperationContext/Web/IncomingRequest.php 2 patches
Unused Use Statements   -2 removed lines patch added patch discarded remove patch
@@ -2,9 +2,7 @@
 block discarded – undo
2 2
 
3 3
 namespace POData\OperationContext\Web;
4 4
 
5
-use POData\Common\ODataException;
6 5
 use POData\Common\ODataConstants;
7
-use POData\Common\Url;
8 6
 use POData\HttpProcessUtility;
9 7
 use POData\OperationContext\HTTPRequestMethod;
10 8
 use POData\OperationContext\IHTTPRequest;
Please login to merge, or discard this patch.
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -152,10 +152,10 @@
 block discarded – undo
152 152
      */
153 153
     public function getRequestHeader($key)
154 154
     {
155
-	    //PHP normalizes header keys
156
-	    $trimmedKey = HttpProcessUtility::headerToServerKey(trim($key));
155
+        //PHP normalizes header keys
156
+        $trimmedKey = HttpProcessUtility::headerToServerKey(trim($key));
157 157
 
158
-	    if (array_key_exists($trimmedKey, $this->_headers)) {
158
+        if (array_key_exists($trimmedKey, $this->_headers)) {
159 159
             return $this->_headers[$trimmedKey];
160 160
         }
161 161
 
Please login to merge, or discard this patch.