NegativeAssertionRunner   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 2
dl 0
loc 18
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\NegativeAssertionRunner
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 negative assertion - throws if any mails match the criteria
17
 *
18
 * @package Ingenerator\Mailhook\Assert
19
 * @see     spec\Ingenerator\Mailhook\Assert\NegativeAssertionRunnerSpec
20
 */
21
class NegativeAssertionRunner extends AssertionRunner {
22
23
	/**
24
	 * @param Email[]        $matched_mails
25
	 * @param EmailMatcher[] $matchers
26
	 *
27
	 * @throws \Ingenerator\Mailhook\EmailAssertionFailedException
28
	 * @return void
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('Unexpected matching emails', $matchers);
35
		}
36
	}
37
38
}
39