|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
/** |
|
6
|
|
|
* Derafu: Biblioteca PHP (Núcleo). |
|
7
|
|
|
* Copyright (C) Derafu <https://www.derafu.org> |
|
8
|
|
|
* |
|
9
|
|
|
* Este programa es software libre: usted puede redistribuirlo y/o modificarlo |
|
10
|
|
|
* bajo los términos de la Licencia Pública General Affero de GNU publicada por |
|
11
|
|
|
* la Fundación para el Software Libre, ya sea la versión 3 de la Licencia, o |
|
12
|
|
|
* (a su elección) cualquier versión posterior de la misma. |
|
13
|
|
|
* |
|
14
|
|
|
* Este programa se distribuye con la esperanza de que sea útil, pero SIN |
|
15
|
|
|
* GARANTÍA ALGUNA; ni siquiera la garantía implícita MERCANTIL o de APTITUD |
|
16
|
|
|
* PARA UN PROPÓSITO DETERMINADO. Consulte los detalles de la Licencia Pública |
|
17
|
|
|
* General Affero de GNU para obtener una información más detallada. |
|
18
|
|
|
* |
|
19
|
|
|
* Debería haber recibido una copia de la Licencia Pública General Affero de GNU |
|
20
|
|
|
* junto a este programa. |
|
21
|
|
|
* |
|
22
|
|
|
* En caso contrario, consulte <http://www.gnu.org/licenses/agpl.html>. |
|
23
|
|
|
*/ |
|
24
|
|
|
|
|
25
|
|
|
namespace Derafu\Lib\Core\Package\Prime\Component\Mail\Support; |
|
26
|
|
|
|
|
27
|
|
|
use Derafu\Lib\Core\Package\Prime\Component\Mail\Contract\MessageInterface; |
|
28
|
|
|
use Symfony\Component\Mime\Email as SymfonyEmail; |
|
29
|
|
|
use Throwable; |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* Clase que representa un mensaje de correo electrónico. |
|
33
|
|
|
*/ |
|
34
|
|
|
class Message extends SymfonyEmail implements MessageInterface |
|
35
|
|
|
{ |
|
36
|
|
|
/** |
|
37
|
|
|
* Identificador único del mensaje (en el contexto del transporte). |
|
38
|
|
|
* |
|
39
|
|
|
* @var int |
|
40
|
|
|
*/ |
|
41
|
|
|
private int $id; |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* Error que ocurrió al transportar el mensaje. |
|
45
|
|
|
* |
|
46
|
|
|
* @var Throwable|null |
|
47
|
|
|
*/ |
|
48
|
|
|
private ?Throwable $error = null; |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* {@inheritDoc} |
|
52
|
|
|
*/ |
|
53
|
|
|
public function id(int $id): static |
|
54
|
|
|
{ |
|
55
|
|
|
$this->id = $id; |
|
56
|
|
|
|
|
57
|
|
|
return $this; |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* {@inheritDoc} |
|
62
|
|
|
*/ |
|
63
|
|
|
public function getId(): int |
|
64
|
|
|
{ |
|
65
|
|
|
return $this->id ?? 0; |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
/** |
|
69
|
|
|
* {@inheritDoc} |
|
70
|
|
|
*/ |
|
71
|
|
|
public function error(Throwable $error): static |
|
72
|
|
|
{ |
|
73
|
|
|
$this->error = $error; |
|
74
|
|
|
|
|
75
|
|
|
return $this; |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
/** |
|
79
|
|
|
* {@inheritDoc} |
|
80
|
|
|
*/ |
|
81
|
|
|
public function getError(): ?Throwable |
|
82
|
|
|
{ |
|
83
|
|
|
return $this->error; |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
|
|
/** |
|
87
|
|
|
* {@inheritDoc} |
|
88
|
|
|
*/ |
|
89
|
|
|
public function hasError(): bool |
|
90
|
|
|
{ |
|
91
|
|
|
return $this->error !== null; |
|
92
|
|
|
} |
|
93
|
|
|
} |
|
94
|
|
|
|