<?php declare(strict_types=1);
namespace Submarine\RedirectsBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity()
* @ORM\Table(name="submarine_redirects_redirects", indexes={@ORM\Index(name="original_url_idx", columns={"original_url"})})
*/
class Redirect
{
/**
* @var int
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id()
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @var string
*
* @ORM\Column(name="original_url", type="string")
*/
private $originalUrl = '';
/**
* @var string
*
* @ORM\Column(name="redirect_url", type="string")
*/
private $redirectUrl = '';
/**
* @var int
*
* @ORM\Column(name="code", type="smallint")
*/
private $code = 301;
/**
* @var bool
*
* @ORM\Column(name="active", type="boolean")
*/
private $active = false;
/**
* @var string
*
* @ORM\Column(name="comment", type="string")
*/
private $comment = '';
/**
* @var \DateTime
*
* @ORM\Column(name="created_at", type="datetime")
*/
private $createdAt;
/**
* @var \DateTime
*
* @ORM\Column(name="updated_at", type="datetime")
*/
private $updatedAt;
/**
* @param string $originalUrl
* @param int $code
* @param int $counter
*/
public function __construct(string $originalUrl = '', int $code = 301)
{
$this->originalUrl = $originalUrl;
$this->code = $code;
$this->createdAt = new \DateTime();
$this->updatedAt = clone $this->createdAt;
}
/**
* @return int
*/
public function getId(): int
{
return $this->id;
}
/**
* @return string
*/
public function getOriginalUrl(): string
{
return $this->originalUrl;
}
/**
* @param string $originalUrl
*/
public function setOriginalUrl(string $originalUrl)
{
$this->originalUrl = $originalUrl;
}
/**
* @return string
*/
public function getRedirectUrl(): string
{
return $this->redirectUrl;
}
/**
* @param string $redirectUrl
*/
public function setRedirectUrl(string $redirectUrl)
{
$this->redirectUrl = $redirectUrl;
}
/**
* @return int
*/
public function getCode(): int
{
return $this->code;
}
/**
* @param int $code
*/
public function setCode(int $code)
{
$this->code = $code;
$this->updatedAt = new \DateTime();
}
/**
* @return bool
*/
public function isActive(): bool
{
return $this->active;
}
/**
* @param bool $active
*/
public function setActive(bool $active)
{
$this->active = $active;
$this->updatedAt = new \DateTime();
}
/**
* @return string
*/
public function getComment(): string
{
return $this->comment;
}
/**
* @param string $comment
*/
public function setComment(string $comment)
{
$this->comment = $comment;
$this->updatedAt = new \DateTime();
}
/**
* @return \DateTime
*/
public function getCreatedAt(): \DateTime
{
return $this->createdAt;
}
/**
* @return \DateTime
*/
public function getUpdatedAt(): \DateTime
{
return $this->updatedAt;
}
}