You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
70 lines
1.4 KiB
70 lines
1.4 KiB
2 years ago
|
<?php
|
||
|
|
||
|
declare(strict_types=1);
|
||
|
|
||
|
namespace App\Entity;
|
||
|
|
||
|
use App\Validator as AppAssert;
|
||
|
use Doctrine\ORM\Mapping as ORM;
|
||
|
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
|
||
|
use Symfony\Component\Validator\Constraints as Assert;
|
||
|
|
||
|
/**
|
||
|
* @ORM\Entity(repositoryClass="App\Repository\UrlRepository")
|
||
|
* @UniqueEntity("customString")
|
||
|
*/
|
||
|
class Url
|
||
|
{
|
||
|
/**
|
||
|
* @ORM\Id
|
||
|
* @ORM\GeneratedValue
|
||
|
* @ORM\Column(type="integer")
|
||
|
*/
|
||
|
private ?int $id;
|
||
|
|
||
|
/**
|
||
|
* @ORM\Column(type="text")
|
||
|
* @Assert\NotBlank
|
||
|
* @Assert\Url
|
||
|
*/
|
||
|
private ?string $longUrl;
|
||
|
|
||
|
/**
|
||
|
* @ORM\Column(type="string", length=11, nullable=true, unique=true)
|
||
|
* @Assert\Length(min=5, max=11)
|
||
|
* @AppAssert\CustomStringNeverCollides
|
||
|
*/
|
||
|
private ?string $customString = null;
|
||
|
|
||
|
public function getId(): int
|
||
|
{
|
||
|
return $this->id;
|
||
|
}
|
||
|
|
||
|
public function getLongUrl(): string
|
||
|
{
|
||
|
return $this->longUrl;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @param string|null $longUrl
|
||
|
* @return Url
|
||
|
*/
|
||
|
public function setLongUrl(?string $longUrl): Url
|
||
|
{
|
||
|
$this->longUrl = $longUrl;
|
||
|
return $this;
|
||
|
}
|
||
|
|
||
|
public function getCustomString(): ?string
|
||
|
{
|
||
|
return $this->customString;
|
||
|
}
|
||
|
|
||
|
public function setCustomString(?string $customString): Url
|
||
|
{
|
||
|
$this->customString = $customString;
|
||
|
return $this;
|
||
|
}
|
||
|
}
|