mirror of
https://github.com/shlinkio/shlink.git
synced 2026-03-06 15:23:12 +08:00
Added new models to pass to repositories when counting visits of any kind
This commit is contained in:
@@ -16,12 +16,18 @@ final class VisitsParams
|
||||
private ?DateRange $dateRange;
|
||||
private int $page;
|
||||
private int $itemsPerPage;
|
||||
private bool $excludeBots;
|
||||
|
||||
public function __construct(?DateRange $dateRange = null, int $page = self::FIRST_PAGE, ?int $itemsPerPage = null)
|
||||
{
|
||||
public function __construct(
|
||||
?DateRange $dateRange = null,
|
||||
int $page = self::FIRST_PAGE,
|
||||
?int $itemsPerPage = null,
|
||||
bool $excludeBots = false
|
||||
) {
|
||||
$this->dateRange = $dateRange ?? new DateRange();
|
||||
$this->page = $page;
|
||||
$this->itemsPerPage = $this->determineItemsPerPage($itemsPerPage);
|
||||
$this->excludeBots = $excludeBots;
|
||||
}
|
||||
|
||||
private function determineItemsPerPage(?int $itemsPerPage): int
|
||||
@@ -39,6 +45,7 @@ final class VisitsParams
|
||||
parseDateRangeFromQuery($query, 'startDate', 'endDate'),
|
||||
(int) ($query['page'] ?? 1),
|
||||
isset($query['itemsPerPage']) ? (int) $query['itemsPerPage'] : null,
|
||||
isset($query['excludeBots']),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -56,4 +63,9 @@ final class VisitsParams
|
||||
{
|
||||
return $this->itemsPerPage;
|
||||
}
|
||||
|
||||
public function excludeBots(): bool
|
||||
{
|
||||
return $this->excludeBots;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user