Code Duplication    Length = 29-29 lines in 2 locations

src/AbstractZohoDao.php 2 locations

@@ 256-284 (lines=29) @@
253
     *
254
     * @throws ZohoCRMResponseException
255
     */
256
    public function getRecords($sortColumnString = null, $sortOrderString = null, \DateTime $lastModifiedTime = null, $selectColumns = null, $limit = null)
257
    {
258
        $globalResponse = array();
259
260
        do {
261
            try {
262
                $fromIndex = count($globalResponse) + 1;
263
                $toIndex = $fromIndex + self::MAX_GET_RECORDS - 1;
264
265
                if ($limit) {
266
                    $toIndex = min($limit - 1, $toIndex);
267
                }
268
269
                $response = $this->zohoClient->getRecords($this->getModule(), $sortColumnString, $sortOrderString, $lastModifiedTime, $selectColumns, $fromIndex, $toIndex);
270
                $beans = $this->getBeansFromResponse($response);
271
            } catch (ZohoCRMResponseException $e) {
272
                // No records found? Let's return an empty array!
273
                if ($e->getCode() == 4422) {
274
                    $beans = array();
275
                } else {
276
                    throw $e;
277
                }
278
            }
279
280
            $globalResponse = array_merge($globalResponse, $beans);
281
        } while (count($beans) == self::MAX_GET_RECORDS);
282
283
        return $globalResponse;
284
    }
285
286
    /**
287
     * Returns the list of deleted records.
@@ 380-408 (lines=29) @@
377
     *
378
     * @throws ZohoCRMResponseException
379
     */
380
    public function searchRecords($searchCondition = null, $limit = null, \DateTime $lastModifiedTime = null, $selectColumns = null)
381
    {
382
        $globalResponse = array();
383
384
        do {
385
            try {
386
                $fromIndex = count($globalResponse) + 1;
387
                $toIndex = $fromIndex + self::MAX_GET_RECORDS - 1;
388
389
                if ($limit) {
390
                    $toIndex = min($limit - 1, $toIndex);
391
                }
392
393
                $response = $this->zohoClient->searchRecords($this->getModule(), $searchCondition, $fromIndex, $toIndex, $lastModifiedTime, $selectColumns);
394
                $beans = $this->getBeansFromResponse($response);
395
            } catch (ZohoCRMResponseException $e) {
396
                // No records found? Let's return an empty array!
397
                if ($e->getCode() == 4422) {
398
                    $beans = array();
399
                } else {
400
                    throw $e;
401
                }
402
            }
403
404
            $globalResponse = array_merge($globalResponse, $beans);
405
        } while (count($beans) == self::MAX_GET_RECORDS);
406
407
        return $globalResponse;
408
    }
409
410
    /**
411
     * Implements insertRecords API method.