Conditions | 6 |
Paths | 4 |
Total Lines | 18 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Tests | 13 |
CRAP Score | 6.0131 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
21 | 8 | public function map($field, $context = null) |
|
22 | { |
||
23 | 8 | $title = 'Please add title'; |
|
24 | |||
25 | 8 | if (array_key_exists('title', $field) && !empty($field['title'])) { |
|
26 | $title = $field['title']; |
||
27 | 8 | } elseif (array_key_exists('fieldName', $field) && !empty($field['fieldName'])) { |
|
28 | 8 | $value = $field['fieldName']; |
|
29 | // Field have dots |
||
30 | 8 | if (strpos($value, '.') !== false) { |
|
31 | 4 | $value = str_replace('.', ' ', str_replace('.0', '.array', $value)); |
|
32 | 4 | } |
|
33 | 8 | $value = preg_replace('/(?<=\\w)(?=[A-Z])/', " $1", $value); |
|
34 | 8 | $title = ucfirst(strtolower($value)); |
|
35 | 8 | } |
|
36 | 8 | $field['title'] = trim($title); |
|
37 | 8 | return $field; |
|
38 | } |
||
39 | } |
||
40 |
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.