PageRenderTime 38ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/cake/libs/overloadable.php

https://github.com/msadouni/cakephp2x
PHP | 92 lines | 24 code | 6 blank | 62 comment | 2 complexity | 2eb210179d3695314537c49a18a21164 MD5 | raw file
  1. <?php
  2. /**
  3. * Overload abstraction interface. Merges differences between PHP4 and 5.
  4. *
  5. * PHP Version 5.x
  6. *
  7. * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
  8. * Copyright 2005-2009, Cake Software Foundation, Inc. (http://cakefoundation.org)
  9. *
  10. * Licensed under The MIT License
  11. * Redistributions of files must retain the above copyright notice.
  12. *
  13. * @copyright Copyright 2005-2009, Cake Software Foundation, Inc. (http://cakefoundation.org)
  14. * @link http://cakephp.org CakePHP(tm) Project
  15. * @package cake
  16. * @subpackage cake.cake.libs
  17. * @since CakePHP(tm) v 1.2
  18. * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
  19. */
  20. /**
  21. * Overloadable class
  22. *
  23. * @package cake
  24. * @subpackage cake.cake.libs
  25. */
  26. class Overloadable extends Object {
  27. /**
  28. * Magic method handler.
  29. *
  30. * @param string $method Method name
  31. * @param array $params Parameters to send to method
  32. * @return mixed Return value from method
  33. * @access private
  34. */
  35. public function __call($method, $params) {
  36. if (!method_exists($this, 'call__')) {
  37. trigger_error(sprintf(__('Magic method handler call__ not defined in %s', true), get_class($this)), E_USER_ERROR);
  38. }
  39. return $this->call__($method, $params);
  40. }
  41. }
  42. /**
  43. * Overloadable2 class
  44. *
  45. * @package cake
  46. * @subpackage cake.cake.libs
  47. */
  48. class Overloadable2 extends Object {
  49. /**
  50. * Magic method handler.
  51. *
  52. * @param string $method Method name
  53. * @param array $params Parameters to send to method
  54. * @return mixed Return value from method
  55. * @access protected
  56. */
  57. public function __call($method, $params) {
  58. if (!method_exists($this, 'call__')) {
  59. trigger_error(sprintf(__('Magic method handler call__ not defined in %s', true), get_class($this)), E_USER_ERROR);
  60. }
  61. return $this->call__($method, $params);
  62. }
  63. /**
  64. * Getter.
  65. *
  66. * @param mixed $name What to get
  67. * @param mixed $value Where to store returned value
  68. * @return boolean Success
  69. * @access protected
  70. */
  71. public function __get($name) {
  72. return $this->get__($name);
  73. }
  74. /**
  75. * Setter.
  76. *
  77. * @param mixed $name What to set
  78. * @param mixed $value Value to set
  79. * @return boolean Success
  80. * @access protected
  81. */
  82. public function __set($name, $value) {
  83. return $this->set__($name, $value);
  84. }
  85. }
  86. ?>