EmailContainingTextMatcher   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 1
dl 0
loc 30
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\EmailContainingTextMatcher
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 an email containing particular body text
16
 *
17
 * @package Ingenerator\Mailhook\Matcher
18
 * @see     spec\Ingenerator\Mailhook\Matcher\EmailContainingTextMatcherSpec
19
 */
20
class EmailContainingTextMatcher implements EmailMatcher {
21
	/**
22
	 * @var string
23
	 */
24
	protected $text;
25
26
	/**
27
	 * @param string $text
28
	 */
29
	public function __construct($text)
30
	{
31
		$this->text = $text;
32
	}
33
34
	/**
35
	 * {@inheritdoc}
36
	 */
37
	public function __toString()
38
	{
39
		return \sprintf('With text "%s"', $this->text);
40
	}
41
42
	/**
43
	 * {@inheritdoc}
44
	 */
45
	public function matches(Email $email)
46
	{
47
		return (\strpos($email->getContent(), $this->text) !== FALSE);
48
	}
49
}
50