Platinum Partner

Object Filter


//+ Jonas Raoni Soares Silva
//@ http://jsfromhell.com

class ObjectFilter{
	protected $o;
	protected $filter;

	public function __construct($o, $filter){
		$this->o = $o;
		$this->filter = is_array($filter) ? $filter : array($filter);
	}
	public function __get($n){
		$s = $this->o->$n;
		foreach($this->filter as $f)
			$s = call_user_func($f, $s);
		return $s;
	}
	public function __set($n, $v){
		return $this->o->$n = $v;
	}
	public function __call($n, $a){
		return call_user_func_array(array($this->o, $n), $a);
	}
	public function getObject(){
		return $this->o;
	}
}


Example


$o = new ObjectFilter(new stdClass, 'strip_tags');
$o->blabla = 'lala';
echo $o->blabla;
{{ tag }}, {{tag}},

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}
{{ parent.authors[0].realName || parent.author}}

{{ parent.authors[0].tagline || parent.tagline }}

{{ parent.views }} ViewsClicks
Tweet

{{parent.nComments}}