<?php

abstract class DataSourceDecorator extends DataSource {



	protected $dataSource;



	public function __construct(IDataSource $dataSource) {
		$this->dataSource = $dataSource;
		$this->id = $dataSource->getId();
	}



	public function fetch() {
		return $this->dataSource->fetch();
	}



	public function __call($method, $args) {
		if (!is_callable($this->dataSource, $method))
			throw new Exception("no such method $method in decorated class ". get_class($this->dataSource));
		return call_user_func(array($this->dataSource, $method), $args);
	}



	public function __get($property) {
		return $this->dataSource->$property;
	}



	public function __set($property, $value) {
		$this->dataSource->$property = $value;
	}


 
} // class DataSourceDecorator

?>