MailhookAsserter::emailsMatching()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
/**
3
 * Defines Ingenerator\Mailhook\MailhookAsserter
4
 *
5
 * @copyright  2014 inGenerator Ltd
6
 * @licence    BSD
7
 */
8
9
namespace Ingenerator\Mailhook;
10
11
use Ingenerator\Mailhook\Assert\NegativeAssertionRunner;
12
use Ingenerator\Mailhook\Assert\PositiveAssertionRunner;
13
14
/**
15
 * Asserts that emails exist matching a
16
 *
17
 * @package Ingenerator\Mailhook
18
 * @see     spec\Ingenerator\Mailhook\MailhookAsserterSpec
19
 */
20
class MailhookAsserter {
21
22
	/**
23
	 * @var Assert\NegativeAssertionRunner
24
	 */
25
	protected $negative_runner;
26
27
	/**
28
	 * @var Assert\PositiveAssertionRunner
29
	 */
30
	protected $positive_runner;
31
32
	public function __construct(
33
		PositiveAssertionRunner $positive_runner,
34
		NegativeAssertionRunner $negative_runner
35
	)
36
	{
37
		$this->positive_runner = $positive_runner;
38
		$this->negative_runner = $negative_runner;
39
	}
40
41
	/**
42
	 * @param EmailMatcher $matcher,... Matchers to run
0 ignored issues
show
Documentation introduced by
There is no parameter named $matcher,.... Did you maybe mean $matcher?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function. It has, however, found a similar but not annotated parameter which might be a good fit.

Consider the following example. The parameter $ireland is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $ireland
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was changed, but the annotation was not.

Loading history...
43
	 *
44
	 * @return Email[]
45
	 */
46
	public function emailsMatching($matcher = NULL)
0 ignored issues
show
Unused Code introduced by
The parameter $matcher is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
47
	{
48
		$matchers = \func_get_args();
49
50
		return $this->positive_runner->assert($matchers);
51
	}
52
53
	/**
54
	 * @param EmailMatcher $matcher,... Matchers to run
0 ignored issues
show
Documentation introduced by
There is no parameter named $matcher,.... Did you maybe mean $matcher?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function. It has, however, found a similar but not annotated parameter which might be a good fit.

Consider the following example. The parameter $ireland is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $ireland
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was changed, but the annotation was not.

Loading history...
55
	 *
56
	 * @return Email
0 ignored issues
show
Documentation introduced by
Should the return type not be Email|null?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
57
	 */
58
	public function firstEmailMatching($matcher = NULL)
0 ignored issues
show
Unused Code introduced by
The parameter $matcher is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
59
	{
60
		$matchers = \func_get_args();
61
		$emails   = $this->positive_runner->assert($matchers);
62
63
		return \array_shift($emails);
64
	}
65
66
	/**
67
	 * @param EmailMatcher $matcher,... Matchers to run
0 ignored issues
show
Documentation introduced by
There is no parameter named $matcher,.... Did you maybe mean $matcher?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function. It has, however, found a similar but not annotated parameter which might be a good fit.

Consider the following example. The parameter $ireland is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $ireland
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was changed, but the annotation was not.

Loading history...
68
	 *
69
	 * @return null
0 ignored issues
show
Documentation introduced by
Should the return type not be Email[]|null?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
70
	 */
71
	public function noEmailMatching($matcher = NULL)
0 ignored issues
show
Unused Code introduced by
The parameter $matcher is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
72
	{
73
		$matchers = \func_get_args();
74
75
		return $this->negative_runner->assert($matchers) ? : NULL;
76
	}
77
}
78