* @return string
*/
public function composeTitle($name) {
+ $substitutions = [
+ 'is_active' => 'Enabled',
+ ];
+ if (isset($substitutions[$name])) {
+ return $substitutions[$name];
+ }
$names = explode('_', strtolower($name));
- $title = '';
- for ($i = 0; $i < count($names); $i++) {
- if ($names[$i] === 'id' || $names[$i] === 'is') {
- // id's do not get titles
- return NULL;
- }
-
- if ($names[$i] === 'im') {
- $names[$i] = 'IM';
+ $allCaps = ['im', 'id'];
+ foreach ($names as $i => $str) {
+ if (in_array($str, $allCaps, TRUE)) {
+ $names[$i] = strtoupper($str);
}
else {
- $names[$i] = ucfirst(trim($names[$i]));
+ $names[$i] = ucfirst(trim($str));
}
-
- $title = $title . ' ' . $names[$i];
}
- return trim($title);
+ return trim(implode(' ', $names));
}
/**