Added DTO used to pass filtering params to VisitsTracker

This commit is contained in:
Alejandro Celaya
2018-11-27 21:09:27 +01:00
parent 03ee46d903
commit 45254606d4
8 changed files with 69 additions and 41 deletions

View File

@@ -0,0 +1,43 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\Core\Model;
use Shlinkio\Shlink\Common\Util\DateRange;
final class VisitsParams
{
/** @var null|DateRange */
private $dateRange;
/** @var int */
private $page = 1;
/** @var null|int */
private $itemsPerPage;
public function __construct(?DateRange $dateRange = null, int $page = 1, ?int $itemsPerPage = null)
{
$this->dateRange = $dateRange ?? new DateRange();
$this->page = $page;
$this->itemsPerPage = $itemsPerPage;
}
public function getDateRange(): DateRange
{
return $this->dateRange;
}
public function getPage(): int
{
return $this->page;
}
public function getItemsPerPage(): ?int
{
return $this->itemsPerPage;
}
public function hasItemsPerPage(): bool
{
return $this->itemsPerPage !== null;
}
}