public function getStatusText($status) { if ($status & self::$ISSUED) { return 'Issued'; } $map = array('Clinical' => self::$CLINICAL_COMPLETE, 'Clerical' => self::$CLERICAL_COMPLETE, 'Demographics' => self::$DEMOGRAPHICS_COMPLETE, 'Consent signature' => self::$CONSENTED, 'Consultant signature' => self::$CONSULTANT_SIGNED); $result = array(); foreach ($map as $label => $flag) { if (($status & $flag) != $flag) { $result[] = $label; } } if (count($result) === count($map)) { return 'Incomplete'; } elseif (count($result) === 0) { return 'Complete'; } else { return 'Incomplete/Missing: ' . implode(', ', $result); } }