Code Duplication    Length = 29-29 lines in 2 locations

src/AbstractZohoDao.php 2 locations

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