Code Duplication    Length = 18-18 lines in 3 locations

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

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

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

@@ 317-334 (lines=18) @@
314
   * @return int
315
   *   The number of the page to display, starting at 0.
316
   */
317
  public function setupPager(Request $request) {
318
    $count = $this->watchdog->templatesCount();
319
    $height = $this->itemsPerPage;
320
    pager_default_initialize($count, $height);
321
322
    $page = intval($request->query->get('page'));
323
    if ($page < 0) {
324
      $page = 0;
325
    }
326
    else {
327
      $page_max = intval(min(ceil($count / $height), PHP_INT_MAX) - 1);
328
      if ($page > $page_max) {
329
        $page = $page_max;
330
      }
331
    }
332
333
    return $page;
334
  }
335
336
}
337

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

@@ 191-208 (lines=18) @@
188
   * @return int
189
   *   The number of the page to display, starting at 0.
190
   */
191
  public function setupPager(Request $request, $uniqueId) {
192
    $count = $this->watchdog->requestEventsCount($uniqueId);
193
    $height = $this->itemsPerPage;
194
    pager_default_initialize($count, $height);
195
196
    $page = intval($request->query->get('page'));
197
    if ($page < 0) {
198
      $page = 0;
199
    }
200
    else {
201
      $page_max = intval(min(ceil($count / $height), PHP_INT_MAX) - 1);
202
      if ($page > $page_max) {
203
        $page = $page_max;
204
      }
205
    }
206
207
    return $page;
208
  }
209
210
  /**
211
   * Convert an absolute path to a relative one if below the site root.