<?php
namespace Org\Enum;
class ExamTypeEnum {
const DANXUAN = 1;
const DUOXUAN = 2;
const PANDUAN = 3;
const TIANKONG = 4;
const WENDA = 5;
const CAILIAO = 6;
private static $_defines = array(
self::DANXUAN => '单选题',
self::DUOXUAN => '多选题',
self::PANDUAN => '判断题',
self::TIANKONG => '填空题',
self::WENDA => '问答题',
self::CAILIAO => '材料题',
);
public function intFromName($name) {
$value = 0;
switch ($name) {
case self::$_defines[self::DANXUAN]:
$value = self::DANXUAN;
break;
case self::$_defines[self::DUOXUAN]:
$value = self::DUOXUAN;
break;
case self::$_defines[self::PANDUAN]:
$value = self::PANDUAN;
break;
case self::$_defines[self::TIANKONG]:
$value = self::TIANKONG;
break;
case self::$_defines[self::WENDA]: $value = self::WENDA; break; case self::$_defines[self::CAILIAO]: $value = self::CAILIAO; break; default: break; } return $value; } public static function isEnum($value) {/* {{{ */ if (isset(self::$_defines[$value])) return true; return false; } /* }}} */ public static function valueOf($value = "", $default = "") { if (self::isEnum($value)) return $value; return $default; } public static function nameOf($value = "", $default = "") { if (self::isEnum($value)) return self::$_defines[$value]; return $default; }}