Completed
Push — master ( 23a82f...29036c )
by Michał
01:51
created

ExposesBcc   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
lcom 1
cbo 0
dl 0
loc 36
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A hideBcc() 0 7 1
A restoreBcc() 0 7 1
1
<?php namespace nyx\notify\transports\mail\drivers\traits;
2
3
// Internal dependencies
4
use nyx\notify\transports\mail;
5
6
/**
7
 * Exposes BCC Mail Driver Trait
8
 *
9
 * Designates a Driver for a provider that does not by itself hide the BCC recipients of a MIME message
10
 * and requires those to be passed in separately from the MIME entity.
11
 *
12
 * @package     Nyx\Notify
13
 * @version     0.1.0
14
 * @author      Michal Chojnacki <[email protected]>
15
 * @copyright   2012-2017 Nyx Dev Team
16
 * @link        https://github.com/unyx/nyx
17
 */
18
trait ExposesBcc
19
{
20
    /**
21
     * The BCC recipients that should not be exposed.
22
     */
23
    protected $bcc;
24
25
    /**
26
     * Removes the BCC recipients from the Message while storing a local in-memory copy that can be restored
27
     * after a mailing transactions.
28
     *
29
     * @param   \Swift_Mime_Message $message    The Message whose BCC recipients the driver should hide.
30
     * @return  $this
31
     */
32
    protected function hideBcc(\Swift_Mime_Message $message) : mail\interfaces\Driver
33
    {
34
        $this->bcc = $message->getBcc();
35
        $message->setBcc([]);
36
37
        return $this;
38
    }
39
40
    /**
41
     * Reapplies the local in-memory copy of a BCC recipient list onto the given Message.
42
     *
43
     * @param   \Swift_Mime_Message $message    The Message to which the BCC recipients list copy should be applied.
44
     * @return  $this
45
     */
46
    protected function restoreBcc(\Swift_Mime_Message $message) : mail\interfaces\Driver
47
    {
48
        $message->setBcc($this->bcc);
49
        $this->bcc = null;
50
51
        return $this;
52
    }
53
}
54