3 * This file is part of the PHPUnit_MockObject package.
5 * (c) Sebastian Bergmann <sebastian@phpunit.de>
7 * For the full copyright and license information, please view the LICENSE
8 * file that was distributed with this source code.
12 * Invocation matcher which looks for a specific method name in the invocations.
14 * Checks the method name all incoming invocations, the name is checked against
15 * the defined constraint $constraint. If the constraint is met it will return
18 * @since Class available since Release 1.0.0
20 class PHPUnit_Framework_MockObject_Matcher_MethodName extends PHPUnit_Framework_MockObject_Matcher_StatelessInvocation
23 * @var PHPUnit_Framework_Constraint
25 protected $constraint;
28 * @param PHPUnit_Framework_Constraint|string
29 * @throws PHPUnit_Framework_Constraint
31 public function __construct($constraint)
33 if (!$constraint instanceof PHPUnit_Framework_Constraint) {
34 if (!is_string($constraint)) {
35 throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string');
38 $constraint = new PHPUnit_Framework_Constraint_IsEqual(
47 $this->constraint = $constraint;
53 public function toString()
55 return 'method name ' . $this->constraint->toString();
59 * @param PHPUnit_Framework_MockObject_Invocation $invocation
62 public function matches(PHPUnit_Framework_MockObject_Invocation $invocation)
64 return $this->constraint->evaluate($invocation->methodName, '', true);