Behavior.class.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. // +--------------------------------------------------------------------------
  3. // | Senthot [ DEVELOPED BY ME ]
  4. // +--------------------------------------------------------------------------
  5. // | Copyright (c) 2005-2013 http://www.senthot.com All rights reserved.
  6. // | License ( http://www.apache.org/licenses/LICENSE-2.0 )
  7. // | Author: ms134n ( [email protected] )
  8. // +--------------------------------------------------------------------------
  9. /**
  10. * Senthot Behavior base class
  11. * @category Sen
  12. * @package Sen
  13. * @subpackage Core
  14. * @author ms134n <[email protected]>
  15. */
  16. abstract class Behavior {
  17. // Behavioral parameters And the same configuration parameter settings
  18. protected $options = array();
  19. /**
  20. * Architecture function
  21. * @access public
  22. */
  23. public function __construct() {
  24. if(!empty($this->options)) {
  25. foreach ($this->options as $name=>$val){
  26. if(NULL !== C($name)) { // Parameters have been set Behavioral parameters overwritten
  27. $this->options[$name] = C($name);
  28. }else{ // Parameter is not set The default value is passed to the configuration
  29. C($name,$val);
  30. }
  31. }
  32. array_change_key_case($this->options);
  33. }
  34. }
  35. // Get behavioral parameters
  36. public function __get($name){
  37. return $this->options[strtolower($name)];
  38. }
  39. /**
  40. * Execution behavior run method is unique interface Behavior
  41. * @access public
  42. * @param mixed $params Behavioral parameters
  43. * @return void
  44. */
  45. abstract public function run(&$params);
  46. }