private function closure(array $values, $calls = null)
{
if ($calls === null) {
$calls = count($values);
}
$Mock = $this->getMock('stdClass', ['method']);
$Mocker = $Mock->expects($this->exactly($calls));
$Mocker->method('method');
$Mocker->will($this->returnValueMap($values));
$with = array_map(function ($arguments) {
return array_slice($arguments, 0, -1);
}, $values);
$Matcher = new ConsecutiveParameters($with);
$Mocker->getMatcher()->parametersMatcher = $Matcher;
$Reflection = new ReflectionClass($Mock);
$Method = $Reflection->getMethod('method');
return $Method->getClosure($Mock);
}