Code Duplication    Length = 18-18 lines in 3 locations

modules/mongodb_watchdog/src/Controller/DetailController.php 1 location

@@ 205-222 (lines=18) @@
202
   * @return int
203
   *   The number of the page to display, starting at 0.
204
   */
205
  public function setupPager(EventTemplate $template, Request $request) {
206
    $count = $this->watchdog->eventCount($template);
207
    $height = $this->itemsPerPage;
208
    pager_default_initialize($count, $height);
209
210
    $page = intval($request->query->get('page'));
211
    if ($page < 0) {
212
      $page = 0;
213
    }
214
    else {
215
      $page_max = intval(min(ceil($count / $height), PHP_INT_MAX) - 1);
216
      if ($page > $page_max) {
217
        $page = $page_max;
218
      }
219
    }
220
221
    return $page;
222
  }
223
224
}
225

modules/mongodb_watchdog/src/Controller/OverviewController.php 1 location

@@ 308-325 (lines=18) @@
305
   * @return int
306
   *   The number of the page to display, starting at 0.
307
   */
308
  public function setupPager(Request $request) {
309
    $count = $this->watchdog->templatesCount();
310
    $height = $this->itemsPerPage;
311
    pager_default_initialize($count, $height);
312
313
    $page = intval($request->query->get('page'));
314
    if ($page < 0) {
315
      $page = 0;
316
    }
317
    else {
318
      $page_max = intval(min(ceil($count / $height), PHP_INT_MAX) - 1);
319
      if ($page > $page_max) {
320
        $page = $page_max;
321
      }
322
    }
323
324
    return $page;
325
  }
326
327
}
328

modules/mongodb_watchdog/src/Controller/RequestController.php 1 location

@@ 219-236 (lines=18) @@
216
   * @return int
217
   *   The number of the page to display, starting at 0.
218
   */
219
  public function setupPager(Request $request, $uniqueId) {
220
    $count = $this->watchdog->requestEventsCount($uniqueId);
221
    $height = $this->itemsPerPage;
222
    pager_default_initialize($count, $height);
223
224
    $page = intval($request->query->get('page'));
225
    if ($page < 0) {
226
      $page = 0;
227
    }
228
    else {
229
      $page_max = intval(min(ceil($count / $height), PHP_INT_MAX) - 1);
230
      if ($page > $page_max) {
231
        $page = $page_max;
232
      }
233
    }
234
235
    return $page;
236
  }
237
238
  /**
239
   * Convert an absolute path to a relative one if below the site root.