<?php
/**
* @author Leo BANNHOLTZER (contact@scaledev.fr)
* @copyright 2021 - ScaleDEV SAS, 12 RUE CHARLES MORET, 10120 ST ANDRE LES VERGERS
* @license commercial
*/
declare(strict_types=1);
namespace App\Entity;
use App\Entity\Traits\OpensslServiceEntity;
use Symfony\Component\Uid\Uuid;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use App\Repository\MailServerRepository;
use Gedmo\Timestampable\Traits\TimestampableEntity;
use Symfony\Bridge\Doctrine\IdGenerator\UuidGenerator;
use App\DoctrineExtensions\SoftDeleteable\Traits\UserSoftDeleteableEntity;
/**
* @ORM\Entity(repositoryClass=MailServerRepository::class)
* @ORM\Table(name="mail_server", indexes={
* @ORM\Index(name="server", columns={"server"}),
* @ORM\Index(name="port", columns={"port"}),
* @ORM\Index(name="login", columns={"login"}),
* @ORM\Index(name="deleted_at", columns={"deleted_at"})
* })
* @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=false, hardDelete=false)
*/
class MailServer
{
use TimestampableEntity;
use UserSoftDeleteableEntity;
use OpensslServiceEntity;
/**
* @ORM\Id
* @ORM\Column(type="uuid")
* @ORM\GeneratedValue(strategy="CUSTOM")
* @ORM\CustomIdGenerator(class=UuidGenerator::class)
*/
private ?Uuid $id = null;
/**
* @ORM\ManyToOne(targetEntity=User::class, inversedBy="mail_servers")
*/
private ?User $user = null;
/**
* @ORM\ManyToOne(targetEntity=Context::class, inversedBy="mail_servers")
*/
private ?Context $context = null;
/**
* @ORM\Column(type="string", length=255)
*/
private string $server;
/**
* @ORM\Column(type="string", length=16)
*/
private string $port;
/**
* @ORM\Column(type="string")
*/
private string $login;
/**
* @ORM\Column(type="string")
*/
private string $password;
/**
* @ORM\Column(type="string", nullable=true)
*/
private ?string $encryption = null;
/**
* @return Uuid|null
*/
public function getId(): ?Uuid
{
return $this->id;
}
/**
* @return User
*/
public function getUser(): ?User
{
return $this->user;
}
/**
* @param User|null $user
* @return $this
*/
public function setUser(?User $user): self
{
$this->user = $user;
return $this;
}
/**
* @return Context|null
*/
public function getContext(): ?Context
{
return $this->context;
}
/**
* @param Context|null $context
* @return $this
*/
public function setContext(?Context $context): self
{
$this->context = $context;
return $this;
}
/**
* @return string
*/
public function getServer(): string
{
return $this->server;
}
/**
* @param string $server
* @return $this
*/
public function setServer(string $server): self
{
$this->server = $server;
return $this;
}
/**
* @return string
*/
public function getPort(): string
{
return $this->port;
}
/**
* @param string $port
* @return $this
*/
public function setPort(string $port): self
{
$this->port = $port;
return $this;
}
/**
* @return string|null
*/
public function getEncryption(): ?string
{
return $this->encryption;
}
/**
* @param string|null $encryption
* @return $this
*/
public function setEncryption(?string $encryption): self
{
$this->encryption = $encryption;
return $this;
}
/**
* @return string
*/
public function getLogin(): string
{
return $this->login;
}
/**
* @param string $login
* @return $this
*/
public function setLogin(string $login): self
{
$this->login = $login;
return $this;
}
/**
* @param bool $decrypt
* @return string
*/
public function getPassword(bool $decrypt = true): string
{
$password = $this->password;
return $decrypt ? $this->openssl->decrypt($password) : $password;
}
/**
* @param string $password
* @return $this
*/
public function setPassword(string $password): self
{
$this->password = $password;
return $this;
}
}