Completed
Push — master ( 6405ba...83526e )
by Walter
19:53 queued 04:58
created

AbstractTransport   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 70
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 1
dl 0
loc 70
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getAddresses() 0 6 1
A getFromAddress() 0 4 1
A setFromAddress() 0 4 1
A getFromName() 0 4 1
A setFromName() 0 4 1
1
<?php
2
/**
3
 * Communicator (https://github.com/waltertamboer/communicator)
4
 *
5
 * @link https://github.com/waltertamboer/communicator for the canonical source repository
6
 * @copyright Copyright (c) 2017 Communicator (https://github.com/waltertamboer/communicator)
7
 * @license https://github.com/waltertamboer/communicator/blob/master/LICENSE.md MIT
8
 */
9
10
namespace Communicator\Transport\Email\Transport;
11
12
use Communicator\Message;
13
use Communicator\Recipient\RecipientInterface;
14
15
/**
16
 * A base class for email transports.
17
 */
18
abstract class AbstractTransport implements TransportInterface
19
{
20
    /**
21
     * The address used as a "from" address.
22
     *
23
     * @var string
24
     */
25
    private $fromAddress;
26
27
    /**
28
     * The name of the sender that belongs to the from address.
29
     *
30
     * @var string
31
     */
32
    private $fromName;
33
34
    /**
35
     * Gets the addresses for this transport.
36
     *
37
     * @param RecipientInterface $recipient
38
     * @param Message $message
39
     * @return array
40
     */
41
    protected function getAddresses(RecipientInterface $recipient, Message $message): array
42
    {
43
        $parameters = (array)$message->getOption('recipient_parameters', []);
44
45
        return $recipient->getNotificationRecipientAddresses('email', $parameters);
46
    }
47
48
    /**
49
     * Gets the value of field "fromAddress".
50
     *
51
     * @return null|string
52
     */
53
    public function getFromAddress(): ?string
54
    {
55
        return $this->fromAddress;
56
    }
57
58
    /**
59
     * Sets the value of field "fromAddress".
60
     *
61
     * @param null|string $fromAddress
62
     */
63
    public function setFromAddress(?string $fromAddress)
64
    {
65
        $this->fromAddress = $fromAddress;
66
    }
67
68
    /**
69
     * Gets the value of field "fromName".
70
     *
71
     * @return null|string
72
     */
73
    public function getFromName(): ?string
74
    {
75
        return $this->fromName;
76
    }
77
78
    /**
79
     * Sets the value of field "fromName".
80
     *
81
     * @param null|string $fromName
82
     */
83
    public function setFromName(?string $fromName)
84
    {
85
        $this->fromName = $fromName;
86
    }
87
}
88