private function generateDocumentStubMethod(ClassMetadataInfo $metadata, $type, $fieldName, $typeHint = null, $defaultValue = null)
{
// Add/remove methods should use the singular form of the field name
$formattedFieldName = in_array($type, array('add', 'remove')) ? Inflector::singularize($fieldName) : $fieldName;
$methodName = $type . Inflector::classify($formattedFieldName);
$variableName = Inflector::camelize($formattedFieldName);
if ($this->hasMethod($methodName, $metadata)) {
return;
}
$description = ucfirst($type) . ' ' . $variableName;
$types = Type::getTypesMap();
$methodTypeHint = $typeHint && !isset($types[$typeHint]) ? '\\' . $typeHint . ' ' : null;
$variableType = $typeHint ? $typeHint . ' ' : null;
$replacements = array('<description>' => $description, '<methodTypeHint>' => $methodTypeHint, '<variableType>' => $variableType, '<variableName>' => $variableName, '<methodName>' => $methodName, '<fieldName>' => $fieldName, '<variableDefault>' => $defaultValue !== null ? ' = ' . $defaultValue : '');
$templateVar = sprintf('%sMethodTemplate', $type);
$method = str_replace(array_keys($replacements), array_values($replacements), self::${$templateVar});
return $this->prefixCodeWithSpaces($method);
}