connect()) exit_with_error('DatabaseConnectionError'); return $db; } function camel_case_words_separated_by_underscore($name) { return implode('', array_map('ucfirst', explode('_', $name))); } function require_format($key, $value, $pattern) { if (!preg_match($pattern, $value)) exit_with_error('Invalid' . camel_case_words_separated_by_underscore($key), array('value' => $value)); } function require_existence_of($array, $list_of_arguments, $prefix = '') { if ($prefix) $prefix .= '_'; foreach ($list_of_arguments as $key => $pattern) { $name = camel_case_words_separated_by_underscore($prefix . $key); if (!array_key_exists($key, $array)) exit_with_error($name . 'NotSpecified'); require_format($name, $array[$key], $pattern); } } ?>