discuz_base.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. /**
  3. * [Discuz!] (C)2001-2099 Discuz! Team
  4. * This is NOT a freeware, use is subject to license terms
  5. * https://license.discuz.vip
  6. */
  7. if(!defined('IN_DISCUZ')) {
  8. exit('Access Denied');
  9. }
  10. abstract class discuz_base {
  11. private $_e;
  12. private $_m;
  13. public function __construct() {
  14. }
  15. public function __set($name, $value) {
  16. $setter = 'set'.$name;
  17. if(method_exists($this, $setter)) {
  18. return $this->$setter($value);
  19. } elseif($this->canGetProperty($name)) {
  20. throw new Exception('The property "'.get_class($this).'->'.$name.'" is readonly');
  21. } else {
  22. throw new Exception('The property "'.get_class($this).'->'.$name.'" is not defined');
  23. }
  24. }
  25. public function __get($name) {
  26. $getter = 'get'.$name;
  27. if(method_exists($this, $getter)) {
  28. return $this->$getter();
  29. } else {
  30. throw new Exception('The property "'.get_class($this).'->'.$name.'" is not defined');
  31. }
  32. }
  33. public function __call($name, $parameters) {
  34. throw new Exception('Class "'.get_class($this).'" does not have a method named "'.$name.'".');
  35. }
  36. public function canGetProperty($name) {
  37. return method_exists($this, 'get'.$name);
  38. }
  39. public function canSetProperty($name) {
  40. return method_exists($this, 'set'.$name);
  41. }
  42. public function __toString() {
  43. return get_class($this);
  44. }
  45. public function __invoke() {
  46. return get_class($this);
  47. }
  48. }