Guest User

Untitled

a guest
Jan 23rd, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. <?php
  2. class Func {
  3. public static $methods = Array();
  4.  
  5. public static function __call($name, $arguments=Array())
  6. {
  7. $dir = DIR_F;
  8. $file = $dir . $name . '.php';
  9.  
  10. if(is_dir($dir) && is_file($file)):
  11.  
  12. if(!isset($this->methods) || !isset($this->methods[$name]))
  13. require_once($file);
  14.  
  15. $this->methods[$name] = true;
  16.  
  17. return call_user_func_array($name, $arguments);
  18.  
  19. else:
  20. die('Function <b>['.$name.']</b> was not found');
  21. return null;
  22. endif;
  23. }
  24.  
  25. public static function __callStatic($name, $arguments=Array())
  26. {
  27. $dir = DIR_F;
  28. $file = $dir . $name . '.php';
  29.  
  30. if(is_dir($dir) && is_file($file)):
  31.  
  32. if(!isset(self::$methods) || !isset(self::$methods[$name]))
  33. require_once($file);
  34.  
  35. self::$methods[$name] = true;
  36. return call_user_func_array($name, $arguments);
  37. else:
  38. die('Function <b>['.$name.']</b> was not found');
  39. return null;
  40. endif;
  41. }
  42.  
  43. public static function object_to_array($object)
  44. {
  45. if(is_array($object) || is_object($object))
  46. {
  47. $array = array();
  48. foreach($object as $key => $value)
  49. {
  50. $array[$key] = object_to_array($value);
  51. }
  52. return $array;
  53. }
  54. return $object;
  55. }
  56.  
  57. // Funcion de Array a Objeto
  58. public static function array_to_object($array = array())
  59. {
  60. return (object) $array;
  61. }
  62. }
  63. ?>
Add Comment
Please, Sign In to add comment