MailComponent::getReceiverWorker()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 2
rs 10
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;
26
27
use Derafu\Lib\Core\Foundation\Abstract\AbstractComponent;
28
use Derafu\Lib\Core\Package\Prime\Component\Mail\Contract\MailComponentInterface;
29
use Derafu\Lib\Core\Package\Prime\Component\Mail\Contract\PostmanInterface;
30
use Derafu\Lib\Core\Package\Prime\Component\Mail\Contract\ReceiverWorkerInterface;
31
use Derafu\Lib\Core\Package\Prime\Component\Mail\Contract\SenderWorkerInterface;
32
33
/**
34
 * Componente de correo electrónico.
35
 *
36
 * Gestiona los correos electrónicos. Tanto el envío mediante SenderWorker y la
37
 * recepción mediante ReceiverWorker.
38
 */
39
class MailComponent extends AbstractComponent implements MailComponentInterface
40
{
41
    /**
42
     * Constructor del componente con sus dependencias.
43
     *
44
     * @param ReceiverWorkerInterface $receiverWorker
45
     * @param SenderWorkerInterface $senderWorker
46
     */
47
    public function __construct(
48
        private ReceiverWorkerInterface $receiverWorker,
49
        private SenderWorkerInterface $senderWorker
50
    ) {
51
    }
52
53
    /**
54
     * {@inheritDoc}
55
     */
56
    public function getWorkers(): array
57
    {
58
        return [
59
            'receiver' => $this->receiverWorker,
60
            'sender' => $this->senderWorker,
61
        ];
62
    }
63
64
    /**
65
     * {@inheritDoc}
66
     */
67
    public function getReceiverWorker(): ReceiverWorkerInterface
68
    {
69
        return $this->receiverWorker;
70
    }
71
72
    /**
73
     * {@inheritDoc}
74
     */
75
    public function getSenderWorker(): SenderWorkerInterface
76
    {
77
        return $this->senderWorker;
78
    }
79
80
    /**
81
     * {@inheritDoc}
82
     */
83
    public function receive(PostmanInterface $postnam): array
84
    {
85
        return $this->receiverWorker->receive($postnam);
86
    }
87
88
    /**
89
     * {@inheritDoc}
90
     */
91
    public function send(PostmanInterface $postnam): array
92
    {
93
        return $this->senderWorker->send($postnam);
94
    }
95
}
96