EmailContainingTextMatcher::__toString()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
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