for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* Verify require Title for fields. Use fieldName otherwise
*/
namespace Graviton\GeneratorBundle\Generator\ResourceGenerator;
* @author List of contributors <https://github.com/libgraviton/graviton/graphs/contributors>
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @link http://swisscom.ch
class FieldTitleMapper implements FieldMapperInterface
{
* @param array $field mappable field with type attribute
* @param mixed $context context for mapper to check
*
* @return array
array<string,string>
This check looks for the generic type array as a return type and suggests a more specific type. This type is inferred from the actual code.
array
public function map($field, $context = null)
$title = 'Please add title';
if (array_key_exists('title', $field) && !empty($field['title'])) {
$title = $field['title'];
} elseif (array_key_exists('fieldName', $field) && !empty($field['fieldName'])) {
// Field can be metadata.action.0.command, so .0 is and Array
$value = str_replace('.0', '.array', $field['fieldName']);
// Field could have metadata.mime So upercase it
$value = ucwords(strtolower($value), '\'.');
$value = str_replace('.', '', $value);
$title = preg_replace('/(?!^)[A-Z]{2,}(?=[A-Z][a-z])|[A-Z][a-z]/', ' $0', $value);
}
$field['title'] = trim($title);
return $field;
This check looks for the generic type
arrayas a return type and suggests a more specific type. This type is inferred from the actual code.