mirror of
https://github.com/Icinga/icingaweb2-module-graphite.git
synced 2026-03-21 18:10:05 -04:00
25 lines
570 B
PHP
25 lines
570 B
PHP
<?php
|
|
|
|
namespace Icinga\Module\Graphite\Forms\TimeRangePicker;
|
|
|
|
use Icinga\Web\UrlParams;
|
|
|
|
trait TimeRangePickerTrait
|
|
{
|
|
/**
|
|
* Extract the relative time range (if any) from the given URL parameters
|
|
*
|
|
* @param UrlParams $params
|
|
*
|
|
* @return bool|int|null
|
|
*/
|
|
protected function getRelativeSeconds(UrlParams $params)
|
|
{
|
|
$seconds = $params->get('graph_range');
|
|
if ($seconds === null) {
|
|
return null;
|
|
}
|
|
|
|
return preg_match('/^(?:0|[1-9]\d*)$/', $seconds) ? (int) $seconds : false;
|
|
}
|
|
}
|