dever.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. /**
  3. * This file is part of Dever.
  4. *
  5. * Licensed under The MIT License
  6. * For full copyright and license information, please see the MIT-LICENSE.txt
  7. * Redistributions of files must retain the above copyright notice.
  8. *
  9. * @author rabin<rabin@shemic.com>
  10. * @copyright rabin<rabin@shemic.com>
  11. * @link http://www.dever.cc/
  12. * @license http://www.opensource.org/licenses/mit-license.php MIT License
  13. */
  14. class Dever
  15. {
  16. /**
  17. * @var array
  18. */
  19. private static $register = array
  20. (
  21. 'load' => array('Import', 'load'),
  22. 'config' => array('Config', 'get'),
  23. 'input' => array('Route', 'input'),
  24. );
  25. /**
  26. * @var array
  27. */
  28. private static $define = array();
  29. /**
  30. * run
  31. */
  32. public static function run()
  33. {
  34. $data = Dever\Route::get();
  35. Dever\Import::load($data['l']);
  36. }
  37. /**
  38. * call
  39. * @param string $name
  40. * @param array $param
  41. * @return mixed
  42. */
  43. public static function __callStatic($name, $param = array())
  44. {
  45. if (isset(self::$register[$name])) {
  46. $class = 'Dever\\' . self::$register[$name][0];
  47. $method = self::$register[$name][1];
  48. return call_user_func_array(array($class, $method), $param);
  49. } elseif (isset(self::$define[$name])) {
  50. if (is_array(self::$define[$name])) {
  51. $class = self::$define[$name][0];
  52. $method = self::$define[$name][1];
  53. } else {
  54. $class = self::$define[$name];
  55. $method = $name;
  56. }
  57. return call_user_func_array(array($class, $method), $param);
  58. }
  59. }
  60. /**
  61. * register
  62. * @param string $method
  63. * @param array $function
  64. * @return mixed
  65. */
  66. public static function reg($method, $function)
  67. {
  68. self::$define[$method] = $function;
  69. }
  70. }