rendered paste body<?php
class Identity {
public function __call($method_name, $arguments){
$get_or_set = substr($method_name,0,3);
switch ($get_or_set){
case 'get':
return $this->getProperty($method_name);
break;
case 'set':
$this->setProperty($method_name,$arguments);
break;
}
}
private function getProperty($method_name){
$property_name = $this->getPropertyName($method_name);
return $this->$property_name;
}
private function setProperty($method_name, $args){
$property_name = $this->getPropertyName($method_name);
$this->$property_name = $args[0];
}
private function getPropertyName($method_name){
return substr(strtolower($method_name),3);
}
}
class Thing extends Identity {
protected $name = 'test name';
}
$thing = new Thing();
print $thing->getName() . "\n";
$thing->setName('pie');
print $thing->getName() . "\n";
?>