public static function formatList(array $items) { switch (count($items)) { case 0: return ''; break; case 1: return reset($items); break; default: $last = array_pop($items); return implode(', ', $items) . ' and ' . $last; } }
/** * Systemic diagnoses shortcode * * @return string */ public function getSyd() { return strtolower(Helper::formatList(Helper::extractValues($this->getSystemicDiagnoses(), 'disorder.term'))); }