Completed
Push — master ( 078292...b58d46 )
by Jonathan
12s
created

DrupalMailManager   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 64
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A startCollectingMail() 0 5 1
A stopCollectingMail() 0 4 1
A enableMail() 0 4 1
A disableMail() 0 4 1
A getMail() 0 4 1
A clearMail() 0 4 1
1
<?php
2
3
namespace Drupal;
4
5
use Drupal\Driver\DriverInterface;
6
7
/**
8
 * Default implementation of the Drupal mail manager service.
9
 *
10
 * This uses Drupal core's test_mail_collector mail backend, which both
11
 * collects outbound mail and prevents it from being sent. Therefore using
12
 * this implementation, mail is collected if and only if sending is disabled.
13
 */
14
class DrupalMailManager implements DrupalMailManagerInterface
15
{
16
17
  /**
18
   * The active Drupal driver.
19
   *
20
   * @var \Drupal\Driver\DriverInterface
21
   */
22
    protected $driver;
23
  
24
    public function __construct(DriverInterface $driver)
25
    {
26
        $this->driver = $driver;
27
    }
28
29
  /**
30
   * {@inheritdoc}
31
   */
32
    public function startCollectingMail()
33
    {
34
        $this->driver->startCollectingMail();
35
        $this->clearMail();
36
    }
37
38
  /**
39
   * {@inheritdoc}
40
   */
41
    public function stopCollectingMail()
42
    {
43
        $this->driver->stopCollectingMail();
44
    }
45
  
46
  /**
47
   * {@inheritdoc}
48
   */
49
    public function enableMail()
50
    {
51
        $this->stopCollectingMail();
52
    }
53
54
  /**
55
   * {@inheritdoc}
56
   */
57
    public function disableMail()
58
    {
59
        $this->startCollectingMail();
60
    }
61
  
62
  /**
63
   * {@inheritdoc}
64
   */
65
    public function getMail($store = 'default')
66
    {
67
        return $this->driver->getMail();
68
    }
69
70
  /**
71
   * {@inheritdoc}
72
   */
73
    public function clearMail($store = 'default')
74
    {
75
        $this->driver->clearMail();
76
    }
77
}
78