mirror of
https://github.com/shlinkio/shlink.git
synced 2025-04-01 14:24:26 +03:00
Improved DateRange to check if both wrapped dates are empty
This commit is contained in:
parent
45d194aced
commit
bdd2d6f8b2
2 changed files with 9 additions and 1 deletions
module
|
@ -33,4 +33,12 @@ class DateRange
|
||||||
{
|
{
|
||||||
return $this->endDate;
|
return $this->endDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function isEmpty()
|
||||||
|
{
|
||||||
|
return is_null($this->startDate) && is_null($this->endDate);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@ class VisitRepository extends EntityRepository implements VisitRepositoryInterfa
|
||||||
$shortUrl = $shortUrl instanceof ShortUrl
|
$shortUrl = $shortUrl instanceof ShortUrl
|
||||||
? $shortUrl
|
? $shortUrl
|
||||||
: $this->getEntityManager()->find(ShortUrl::class, $shortUrl);
|
: $this->getEntityManager()->find(ShortUrl::class, $shortUrl);
|
||||||
if (! isset($dateRange)) {
|
if (! isset($dateRange) || $dateRange->isEmpty()) {
|
||||||
$startDate = $shortUrl->getDateCreated();
|
$startDate = $shortUrl->getDateCreated();
|
||||||
$endDate = clone $startDate;
|
$endDate = clone $startDate;
|
||||||
$endDate->add(new \DateInterval('P2D'));
|
$endDate->add(new \DateInterval('P2D'));
|
||||||
|
|
Loading…
Add table
Reference in a new issue