PageRenderTime 41ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/source/class/discuz/discuz_base.php

https://github.com/jinbo51/DiscuzX
PHP | 66 lines | 47 code | 13 blank | 6 comment | 5 complexity | 491a3ff645305fffd7734495ac844000 MD5 | raw file
Possible License(s): BSD-3-Clause
  1. <?php
  2. /**
  3. * [Discuz!] (C)2001-2099 Comsenz Inc.
  4. * This is NOT a freeware, use is subject to license terms
  5. *
  6. * $Id: discuz_base.php 30321 2012-05-22 09:09:35Z zhangguosheng $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. abstract class discuz_base
  12. {
  13. private $_e;
  14. private $_m;
  15. public function __construct() {
  16. }
  17. public function __set($name, $value) {
  18. $setter='set'.$name;
  19. if(method_exists($this,$setter)) {
  20. return $this->$setter($value);
  21. } elseif($this->canGetProperty($name)) {
  22. throw new Exception('The property "'.get_class($this).'->'.$name.'" is readonly');
  23. } else {
  24. throw new Exception('The property "'.get_class($this).'->'.$name.'" is not defined');
  25. }
  26. }
  27. public function __get($name) {
  28. $getter='get'.$name;
  29. if(method_exists($this,$getter)) {
  30. return $this->$getter();
  31. } else {
  32. throw new Exception('The property "'.get_class($this).'->'.$name.'" is not defined');
  33. }
  34. }
  35. public function __call($name,$parameters) {
  36. throw new Exception('Class "'.get_class($this).'" does not have a method named "'.$name.'".');
  37. }
  38. public function canGetProperty($name)
  39. {
  40. return method_exists($this,'get'.$name);
  41. }
  42. public function canSetProperty($name)
  43. {
  44. return method_exists($this,'set'.$name);
  45. }
  46. public function __toString() {
  47. return get_class($this);
  48. }
  49. public function __invoke() {
  50. return get_class($this);
  51. }
  52. }
  53. ?>