Code Duplication    Length = 15-17 lines in 2 locations

services/NorthWind/NorthWindQueryProvider.php 2 locations

@@ 296-310 (lines=15) @@
293
        $srcClass = get_class($sourceEntityInstance);
294
        $navigationPropName = $targetProperty->getName();
295
        if ($srcClass === 'Customer') {
296
            if ($navigationPropName === 'Orders') {                
297
                $query = "SELECT * FROM Orders WHERE CustomerID = '$sourceEntityInstance->CustomerID'";
298
                if ($filterOption != null) {
299
                    $query .= ' AND ' . $filterOption;
300
                }
301
                $stmt = sqlsrv_query($this->_connectionHandle, $query);
302
                if ($stmt === false) {
303
                    $errorAsString = self::_getSQLSRVError();
304
        	        throw ODataException::createInternalServerError($errorAsString);
305
                }
306
307
                $result = $this->_serializeOrders($stmt);
308
            } else {
309
                die('Customer does not have navigation porperty with name: ' . $navigationPropName);
310
            }            
311
        } else if ($srcClass === 'Order') {
312
            if ($navigationPropName === 'Order_Details') {
313
                $query = "SELECT * FROM [Order Details] WHERE OrderID = $sourceEntityInstance->OrderID";
@@ 311-327 (lines=17) @@
308
            } else {
309
                die('Customer does not have navigation porperty with name: ' . $navigationPropName);
310
            }            
311
        } else if ($srcClass === 'Order') {
312
            if ($navigationPropName === 'Order_Details') {
313
                $query = "SELECT * FROM [Order Details] WHERE OrderID = $sourceEntityInstance->OrderID";
314
                if ($filterOption != null) {
315
                    $query .= ' AND ' . $filterOption;
316
                }
317
                $stmt = sqlsrv_query($this->_connectionHandle, $query);
318
                if ($stmt === false) {            
319
                    $errorAsString = self::_getSQLSRVError();
320
        	        throw ODataException::createInternalServerError($errorAsString);
321
                }
322
323
                $result = $this->_serializeOrderDetails($stmt);
324
            } else {
325
                die('Order does not have navigation porperty with name: ' . $navigationPropName);
326
            }
327
        }
328
329
        return $result;
330
    }