Code Duplication    Length = 29-29 lines in 2 locations

src/AbstractZohoDao.php 2 locations

@@ 297-325 (lines=29) @@
294
     * @throws ZohoCRMResponseException
295
     * @throws \Exception
296
     */
297
    public function getDeletedRecordIds(\DateTimeInterface $lastModifiedTime = null, $limit = null)
298
    {
299
        $globalDeletedIDs = array();
300
301
        do {
302
            try {
303
                $fromIndex = count($globalDeletedIDs) + 1;
304
                $toIndex = $fromIndex + self::MAX_GET_RECORDS - 1;
305
306
                if ($limit) {
307
                    $toIndex = min($limit - 1, $toIndex);
308
                }
309
310
                $response = $this->zohoClient->getDeletedRecordIds($this->getModule(), $lastModifiedTime, $fromIndex, $toIndex);
311
                $deletedIDs = $response->getDeletedIds();
312
            } catch (ZohoCRMResponseException $e) {
313
                // No records found? Let's return an empty array!
314
                if ($e->getZohoCode() == 4422) {
315
                    $deletedIDs = array();
316
                } else {
317
                    throw $e;
318
                }
319
            }
320
321
            $globalDeletedIDs = array_merge($globalDeletedIDs, $deletedIDs);
322
        } while (count($deletedIDs) == self::MAX_GET_RECORDS);
323
324
        return $globalDeletedIDs;
325
    }
326
327
    /**
328
     * Implements getRecords API method.
@@ 338-366 (lines=29) @@
335
     *
336
     * @throws ZohoCRMResponseException
337
     */
338
    public function getRelatedRecords($id, $parentModule, $limit = null)
339
    {
340
        $globalResponse = array();
341
342
        do {
343
            try {
344
                $fromIndex = count($globalResponse) + 1;
345
                $toIndex = $fromIndex + self::MAX_GET_RECORDS - 1;
346
347
                if ($limit) {
348
                    $toIndex = min($limit - 1, $toIndex);
349
                }
350
351
                $response = $this->zohoClient->getRelatedRecords($this->getModule(), $id, $parentModule, $fromIndex, $toIndex);
352
                $beans = $this->getBeansFromResponse($response);
353
            } catch (ZohoCRMResponseException $e) {
354
                // No records found? Let's return an empty array!
355
                if ($e->getCode() == 4422) {
356
                    $beans = array();
357
                } else {
358
                    throw $e;
359
                }
360
            }
361
362
            $globalResponse = array_merge($globalResponse, $beans);
363
        } while (count($beans) == self::MAX_GET_RECORDS);
364
365
        return $globalResponse;
366
    }
367
368
    /**
369
     * Implements searchRecords API method.