EmailSentToMatcher   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 1
dl 0
loc 31
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A __toString() 0 4 1
A matches() 0 4 1
1
<?php
2
/**
3
 * Defines Ingenerator\Mailhook\Matcher\EmailSentToMatcher
4
 *
5
 * @copyright  2014 inGenerator Ltd
6
 * @licence    BSD
7
 */
8
9
namespace Ingenerator\Mailhook\Matcher;
10
11
use Ingenerator\Mailhook\Email;
12
use Ingenerator\Mailhook\EmailMatcher;
13
14
/**
15
 * Matches the recipient email address
16
 *
17
 * @package Ingenerator\Mailhook\Matcher
18
 * @see     spec\Ingenerator\Mailhook\Matcher\EmailSentToMatcherSpec
19
 */
20
class EmailSentToMatcher implements EmailMatcher {
21
22
	/**
23
	 * @var string
24
	 */
25
	protected  $recipient;
26
27
	/**
28
	 * @param string $recipient
29
	 */
30
	public function __construct($recipient)
31
	{
32
		$this->recipient = $recipient;
33
	}
34
35
	/**
36
	 * {@inheritdoc}
37
	 */
38
	public function __toString()
39
	{
40
		return \sprintf('To "%s"', $this->recipient);
41
	}
42
43
	/**
44
	 * {@inheritdoc}
45
	 */
46
	public function matches(Email $email)
47
	{
48
		return ($email->getTo() === $this->recipient);
49
	}
50
}
51