Email   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 79
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

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

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 2
A getContent() 0 4 1
A getLinks() 0 4 1
A getLinksMatching() 0 8 1
A getSubject() 0 4 1
A getTo() 0 4 1
1
<?php
2
/**
3
 * Models a single email
4
 *
5
 * @author    Andrew Coulton <[email protected]>
6
 * @copyright 2014 inGenerator Ltd
7
 * @licence   BSD
8
 */
9
10
namespace Ingenerator\Mailhook;
11
12
class Email {
13
14
	/**
15
	 * @var string
16
	 */
17
	protected $content;
18
19
	/**
20
	 * @var string[]
21
	 */
22
	protected $links = array();
23
24
	/**
25
	 * @var string
26
	 */
27
	protected $subject;
28
29
	/**
30
	 * @var string
31
	 */
32
	protected $to;
33
34
	/**
35
	 * @param string[] $data
36
	 */
37
	public function __construct($data)
38
	{
39
		foreach ($data as $field => $value)
40
		{
41
			$this->$field = $value;
42
		}
43
	}
44
45
	/**
46
	 * @return string
47
	 */
48
	public function getContent()
49
	{
50
		return $this->content;
51
	}
52
53
	/**
54
	 * @return string[] the urls of all links in the email
55
	 */
56
	public function getLinks()
57
	{
58
		return $this->links;
59
	}
60
61
	/**
62
	 * @param string $pattern regular expression
63
	 *
64
	 * @return \string[] the urls matching the pattern
65
	 */
66
	public function getLinksMatching($pattern)
67
	{
68
		return \array_filter($this->links, function ($link) use ($pattern)
69
			{
70
				return \preg_match($pattern, $link);
71
			}
72
		);
73
	}
74
75
	/**
76
	 * @return string
77
	 */
78
	public function getSubject()
79
	{
80
		return $this->subject;
81
	}
82
83
	/**
84
	 * @return string
85
	 */
86
	public function getTo()
87
	{
88
		return $this->to;
89
	}
90
}
91