Code Duplication    Length = 20-22 lines in 2 locations

services/NorthWind/NorthWindQueryProvider.php 2 locations

@@ 353-372 (lines=20) @@
350
        $srcClass = get_class($sourceEntityInstance);
351
        $navigationPropName = $targetProperty->getName();
352
        if ($srcClass === 'Order') {
353
            if ($navigationPropName === 'Customer') {
354
                if (empty($sourceEntityInstance->CustomerID)) {
355
                    $result = null;
356
                } else {                    
357
                    $query = "SELECT * FROM Customers WHERE CustomerID = '$sourceEntityInstance->CustomerID'";                
358
                    $stmt = sqlsrv_query($this->_connectionHandle, $query);
359
                    if ($stmt === false) {
360
                        $errorAsString = self::_getSQLSRVError();
361
        	            throw ODataException::createInternalServerError($errorAsString);
362
                    }
363
364
                    if (!sqlsrv_has_rows($stmt)) {
365
                        $result =  null;
366
                    }
367
368
                    $result = $this->_serializeCustomer(sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC));
369
                }
370
            } else {
371
                die('Customer does not have navigation porperty with name: ' . $navigationPropName);
372
            }            
373
        } else if ($srcClass === 'Order_Details') {
374
            if ($navigationPropName === 'Order') {
375
                if (empty($sourceEntityInstance->OrderID)) {
@@ 373-394 (lines=22) @@
370
            } else {
371
                die('Customer does not have navigation porperty with name: ' . $navigationPropName);
372
            }            
373
        } else if ($srcClass === 'Order_Details') {
374
            if ($navigationPropName === 'Order') {
375
                if (empty($sourceEntityInstance->OrderID)) {
376
                    $result = null;
377
                } else {
378
                    $query = "SELECT * FROM Orders WHERE OrderID = $sourceEntityInstance->OrderID";
379
                    $stmt = sqlsrv_query($this->_connectionHandle, $query);
380
                    if ($stmt === false) {
381
                        $errorAsString = self::_getSQLSRVError();
382
        	            throw ODataException::createInternalServerError($errorAsString);
383
                    }
384
                    
385
                    if (!sqlsrv_has_rows($stmt)) {
386
                        $result =  null;
387
                    }
388
                    
389
                    $result = $this->_serializeOrder(sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC));
390
                }
391
            } else {
392
                die('Order_Details does not have navigation porperty with name: ' . $navigationPropName);
393
            }
394
        } 
395
396
        return $result;
397
    }