Code Duplication    Length = 29-29 lines in 2 locations

src/AbstractZohoDao.php 2 locations

@@ 288-316 (lines=29) @@
285
     *
286
     * @throws ZohoCRMResponseException
287
     */
288
    public function getRecords($sortColumnString = null, $sortOrderString = null, \DateTime $lastModifiedTime = null, $selectColumns = null, $limit = null)
289
    {
290
        $globalResponse = array();
291
292
        do {
293
            try {
294
                $fromIndex = count($globalResponse) + 1;
295
                $toIndex = $fromIndex + self::MAX_GET_RECORDS - 1;
296
297
                if ($limit) {
298
                    $toIndex = min($limit, $toIndex);
299
                }
300
301
                $response = $this->zohoClient->getRecords($this->getModule(), $sortColumnString, $sortOrderString, $lastModifiedTime, $selectColumns, $fromIndex, $toIndex);
302
                $beans = $this->getBeansFromResponse($response);
303
            } catch (ZohoCRMResponseException $e) {
304
                // No records found? Let's return an empty array!
305
                if ($e->getCode() == 4422) {
306
                    $beans = array();
307
                } else {
308
                    throw $e;
309
                }
310
            }
311
312
            $globalResponse = array_merge($globalResponse, $beans);
313
        } while (count($beans) == self::MAX_GET_RECORDS);
314
315
        return $globalResponse;
316
    }
317
318
    /**
319
     * Returns the list of deleted records.
@@ 412-440 (lines=29) @@
409
     *
410
     * @throws ZohoCRMResponseException
411
     */
412
    public function searchRecords($searchCondition = null, $limit = null, \DateTime $lastModifiedTime = null, $selectColumns = null)
413
    {
414
        $globalResponse = array();
415
416
        do {
417
            try {
418
                $fromIndex = count($globalResponse) + 1;
419
                $toIndex = $fromIndex + self::MAX_GET_RECORDS - 1;
420
421
                if ($limit) {
422
                    $toIndex = min($limit - 1, $toIndex);
423
                }
424
425
                $response = $this->zohoClient->searchRecords($this->getModule(), $searchCondition, $fromIndex, $toIndex, $lastModifiedTime, $selectColumns);
426
                $beans = $this->getBeansFromResponse($response);
427
            } catch (ZohoCRMResponseException $e) {
428
                // No records found? Let's return an empty array!
429
                if ($e->getCode() == 4422) {
430
                    $beans = array();
431
                } else {
432
                    throw $e;
433
                }
434
            }
435
436
            $globalResponse = array_merge($globalResponse, $beans);
437
        } while (count($beans) == self::MAX_GET_RECORDS);
438
439
        return $globalResponse;
440
    }
441
442
    /**
443
     * Implements insertRecords API method.