Skip to content

Instantly share code, notes, and snippets.

@lkwdwrd
Created January 4, 2016 00:33
Show Gist options
  • Save lkwdwrd/f1ec41e1c388a36639a2 to your computer and use it in GitHub Desktop.
Save lkwdwrd/f1ec41e1c388a36639a2 to your computer and use it in GitHub Desktop.
Reflector Decorator Play
<?php
namespace WP_Parser\Reflection;
use WP_Parser\Reflection\Reflector_Meta;
final class Reflector_Decorator {
use Reflector_Meta;
private $_reflector;
public function __construct( $reflector ) {
$this->_reflector = $reflector;
}
public function __call( $method, $args ) {
if ( method_exists( $this->_class_reflector, $method ) ) {
return call_user_func_array( array( $this->_class_reflector, $method ), $args );
}
}
}
<?php
namespace WP_Parser\Reflection;
trait Reflector_Meta {
private $_meta = array();
public function addMeta( $name, $value ) {
$this->_meta[ $name ] = $value;
}
public function getMeta( $name ) {
return ( isset( $this->_meta[ $name ] ) ) ? $this->_meta[ $name ] : null;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment