Кстати, никаких свитчей. Вот тебе реализация а-ля Delphi:
PHP:
<?
class Foo {
private $_var;
protected function var_get() { return $this->_var; }
protected function var_set($value) { $this->_var = $value; }
function __get($var) {
if (method_exists($this, $method = $var.'_get')) return $this->$method();
}
function __set($var, $value) {
if (method_exists($this, $method = $var.'_set')) $this->$method($value);
}
}
$bar = new Foo();
$bar->var = 10;
echo $bar->var;
?>