public final function generateCode(ReflectionClass $class, $test_double_class_name, array $interfaces = array(), array $traits = array(), $method_checker = null)
{
FBMock_Utils::assertString($test_double_class_name);
if ($class->isFinal() && !$this->canOverrideFinals()) {
throw new FBMock_TestDoubleException("Cannot mock final class %s", $class->getName());
}
$code = $this->getMockClassHeader($class, $test_double_class_name, $interfaces, $traits) . "\n";
$method_sources = array();
foreach ($class->getMethods() as $method) {
$method_checker && $method_checker($class, $method);
if ($method->isFinal() && !$this->canOverrideFinals()) {
continue;
}
// #1137433
if (!$class->isInterface()) {
$method = new ReflectionMethod($class->getName(), $method->getName());
}
$test_double_method_generator = FBMock_Config::get()->getMethodGenerator();
$method_source = $test_double_method_generator->generateCode($method);
if ($method_source) {
$method_sources[] = $method_source;
}
}
$code .= implode("\n\n", $method_sources);
$code .= "\n}";
// close class
return $code;
}