Implement option to replace existing alias when renaming an account; use database transactions when editing accounts
This commit is contained in:
parent
6ace072841
commit
36b8cfe8b1
7 changed files with 163 additions and 15 deletions
65
src/Models/Alias.php
Normal file
65
src/Models/Alias.php
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace MailAccountAdmin\Models;
|
||||
|
||||
use DateTimeImmutable;
|
||||
|
||||
class Alias
|
||||
{
|
||||
/** @var int */
|
||||
private $id;
|
||||
/** @var int */
|
||||
private $userId;
|
||||
/** @var string */
|
||||
private $mailAddress;
|
||||
/** @var DateTimeImmutable */
|
||||
private $createdAt;
|
||||
/** @var DateTimeImmutable */
|
||||
private $modifiedAt;
|
||||
|
||||
private function __construct(int $id, int $userId, string $mailAddress, DateTimeImmutable $createdAt, DateTimeImmutable $modifiedAt)
|
||||
{
|
||||
$this->id = $id;
|
||||
$this->userId = $userId;
|
||||
$this->mailAddress = $mailAddress;
|
||||
$this->createdAt = $createdAt;
|
||||
$this->modifiedAt = $modifiedAt;
|
||||
}
|
||||
|
||||
public static function createFromArray(array $data): self
|
||||
{
|
||||
return new self(
|
||||
(int)$data['alias_id'],
|
||||
(int)$data['user_id'],
|
||||
$data['mail_address'],
|
||||
new DateTimeImmutable($data['created_at']),
|
||||
new DateTimeImmutable($data['modified_at']),
|
||||
);
|
||||
}
|
||||
|
||||
public function getId(): int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getUserId(): int
|
||||
{
|
||||
return $this->userId;
|
||||
}
|
||||
|
||||
public function getMailAddress(): string
|
||||
{
|
||||
return $this->mailAddress;
|
||||
}
|
||||
|
||||
public function getCreatedAt(): DateTimeImmutable
|
||||
{
|
||||
return $this->createdAt;
|
||||
}
|
||||
|
||||
public function getModifiedAt(): DateTimeImmutable
|
||||
{
|
||||
return $this->modifiedAt;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue