Code Duplication    Length = 18-18 lines in 3 locations

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/DetailController.php 1 location

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

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

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