OpeCode.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. namespace loyalsoft;
  3. /**
  4. * 功能码常量定义, 要求: 常量名称和对应的功能处理模块的名称相一致(无需Proc后缀).
  5. * @author gwang
  6. */
  7. class OpeCode {
  8. /**
  9. * 支付功能
  10. */
  11. const Pay = 888;
  12. /**
  13. * 玩家主功能
  14. */
  15. const User = 600;
  16. // <editor-fold defaultstate="collapsed" desc="反射方法">
  17. //
  18. /**
  19. * 依据opecode=> Proc模块名称
  20. * @param type $ope
  21. * @return string
  22. * @author gwang
  23. */
  24. public static function getProc($ope) {
  25. $r = new \ReflectionClass(__CLASS__); # 新建反射对象
  26. $procs = array_flip($r->getConstants()); # 提取操作码到数组中
  27. if (!isset($procs[$ope])) { # 找不到
  28. return 'err'; # 返回固定的字符串: err
  29. }
  30. return __NAMESPACE__ . '\\' . $procs[$ope] . 'Proc'; # 拼装处理模块的名称
  31. }
  32. // </editor-fold>
  33. }