Ensured pagination params in visits list are properly parsed to integer

This commit is contained in:
Alejandro Celaya
2018-11-28 20:53:04 +01:00
parent 4d2684be52
commit 1d4ef4e9a4
2 changed files with 9 additions and 2 deletions

View File

@@ -27,7 +27,11 @@ final class VisitsParams
$startDate = self::getDateQueryParam($query, 'startDate');
$endDate = self::getDateQueryParam($query, 'endDate');
return new self(new DateRange($startDate, $endDate), $query['page'] ?? 1, $query['itemsPerPage'] ?? null);
return new self(
new DateRange($startDate, $endDate),
(int) ($query['page'] ?? 1),
isset($query['itemsPerPage']) ? (int) $query['itemsPerPage'] : null
);
}
private static function getDateQueryParam(array $query, string $key): ?Chronos