PositiveAssertionRunner   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 2
dl 0
loc 17
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A do_assert() 0 7 2
1
<?php
2
/**
3
 * Defines Ingenerator\Mailhook\Assert\PositiveAssertionRunner
4
 *
5
 * @copyright  2014 inGenerator Ltd
6
 * @licence    BSD
7
 */
8
9
namespace Ingenerator\Mailhook\Assert;
10
11
use Ingenerator\Mailhook\Email;
12
use Ingenerator\Mailhook\EmailAssertionFailedException;
13
use Ingenerator\Mailhook\EmailMatcher;
14
15
/**
16
 * Runs a positive assertion - one that throws if no emails match the provided criteria
17
 *
18
 * @package Ingenerator\Mailhook\Assert
19
 * @see     spec\Ingenerator\Mailhook\Assert\PositiveAssertionRunnerSpec
20
 */
21
class PositiveAssertionRunner extends AssertionRunner {
22
23
	/**
24
	 * @param Email[]        $matched_mails
25
	 * @param EmailMatcher[] $matchers
26
	 *
27
	 * @return void
28
	 * @throws \Ingenerator\Mailhook\EmailAssertionFailedException
29
	 */
30
	protected function do_assert($matched_mails, $matchers)
31
	{
32
		if ( ! $matched_mails)
0 ignored issues
show
Bug Best Practice introduced by
The expression $matched_mails of type Ingenerator\Mailhook\Email[] is implicitly converted to a boolean; are you sure this is intended? If so, consider using empty($expr) instead to make it clear that you intend to check for an array without elements.

This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.

Consider making the comparison explicit by using empty(..) or ! empty(...) instead.

Loading history...
33
		{
34
			throw new EmailAssertionFailedException('No emails matched criteria', $matchers);
35
		}
36
	}
37
}
38