mirror of
https://github.com/shlinkio/shlink.git
synced 2026-03-10 01:03:13 +08:00
Updated UrlShortener so that it does not match a short code which is out of the validity dat erange
This commit is contained in:
@@ -54,22 +54,32 @@ class ShortUrl extends AbstractEntity implements \JsonSerializable
|
||||
* })
|
||||
*/
|
||||
protected $tags;
|
||||
/**
|
||||
* @var \DateTime
|
||||
* @ORM\Column(name="valid_since", type="datetime", nullable=true)
|
||||
*/
|
||||
protected $validSince;
|
||||
/**
|
||||
* @var \DateTime
|
||||
* @ORM\Column(name="valid_until", type="datetime", nullable=true)
|
||||
*/
|
||||
protected $validUntil;
|
||||
|
||||
/**
|
||||
* ShortUrl constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->setDateCreated(new \DateTime());
|
||||
$this->setVisits(new ArrayCollection());
|
||||
$this->setShortCode('');
|
||||
$this->dateCreated = new \DateTime();
|
||||
$this->visits = new ArrayCollection();
|
||||
$this->shortCode = '';
|
||||
$this->tags = new ArrayCollection();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getOriginalUrl()
|
||||
public function getOriginalUrl(): string
|
||||
{
|
||||
return $this->originalUrl;
|
||||
}
|
||||
@@ -78,7 +88,7 @@ class ShortUrl extends AbstractEntity implements \JsonSerializable
|
||||
* @param string $originalUrl
|
||||
* @return $this
|
||||
*/
|
||||
public function setOriginalUrl($originalUrl)
|
||||
public function setOriginalUrl(string $originalUrl)
|
||||
{
|
||||
$this->originalUrl = (string) $originalUrl;
|
||||
return $this;
|
||||
@@ -87,7 +97,7 @@ class ShortUrl extends AbstractEntity implements \JsonSerializable
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getShortCode()
|
||||
public function getShortCode(): string
|
||||
{
|
||||
return $this->shortCode;
|
||||
}
|
||||
@@ -96,7 +106,7 @@ class ShortUrl extends AbstractEntity implements \JsonSerializable
|
||||
* @param string $shortCode
|
||||
* @return $this
|
||||
*/
|
||||
public function setShortCode($shortCode)
|
||||
public function setShortCode(string $shortCode)
|
||||
{
|
||||
$this->shortCode = $shortCode;
|
||||
return $this;
|
||||
@@ -105,7 +115,7 @@ class ShortUrl extends AbstractEntity implements \JsonSerializable
|
||||
/**
|
||||
* @return \DateTime
|
||||
*/
|
||||
public function getDateCreated()
|
||||
public function getDateCreated(): \DateTime
|
||||
{
|
||||
return $this->dateCreated;
|
||||
}
|
||||
@@ -114,34 +124,16 @@ class ShortUrl extends AbstractEntity implements \JsonSerializable
|
||||
* @param \DateTime $dateCreated
|
||||
* @return $this
|
||||
*/
|
||||
public function setDateCreated($dateCreated)
|
||||
public function setDateCreated(\DateTime $dateCreated)
|
||||
{
|
||||
$this->dateCreated = $dateCreated;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Visit[]|Collection
|
||||
*/
|
||||
public function getVisits()
|
||||
{
|
||||
return $this->visits;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Visit[]|Collection $visits
|
||||
* @return $this
|
||||
*/
|
||||
public function setVisits($visits)
|
||||
{
|
||||
$this->visits = $visits;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection|Tag[]
|
||||
*/
|
||||
public function getTags()
|
||||
public function getTags(): Collection
|
||||
{
|
||||
return $this->tags;
|
||||
}
|
||||
@@ -150,7 +142,7 @@ class ShortUrl extends AbstractEntity implements \JsonSerializable
|
||||
* @param Collection|Tag[] $tags
|
||||
* @return $this
|
||||
*/
|
||||
public function setTags($tags)
|
||||
public function setTags(Collection $tags)
|
||||
{
|
||||
$this->tags = $tags;
|
||||
return $this;
|
||||
@@ -166,6 +158,42 @@ class ShortUrl extends AbstractEntity implements \JsonSerializable
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \DateTime|null
|
||||
*/
|
||||
public function getValidSince()
|
||||
{
|
||||
return $this->validSince;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \DateTime|null $validSince
|
||||
* @return $this|self
|
||||
*/
|
||||
public function setValidSince($validSince): self
|
||||
{
|
||||
$this->validSince = $validSince;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \DateTime|null
|
||||
*/
|
||||
public function getValidUntil()
|
||||
{
|
||||
return $this->validUntil;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \DateTime|null $validUntil
|
||||
* @return $this|self
|
||||
*/
|
||||
public function setValidUntil($validUntil): self
|
||||
{
|
||||
$this->validUntil = $validUntil;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify data which should be serialized to JSON
|
||||
* @link http://php.net/manual/en/jsonserializable.jsonserialize.php
|
||||
|
||||
Reference in New Issue
Block a user