Skip to content

Instantly share code, notes, and snippets.

@iamdey
Created March 26, 2013 10:28
Show Gist options
  • Save iamdey/5244405 to your computer and use it in GitHub Desktop.
Save iamdey/5244405 to your computer and use it in GitHub Desktop.
Proxy class creation
<?php
namespace Reflected;
use A as Base;
/**
* Proxy class exemple
*
* @author depely
*/
class A extends Base
{
public function __construct(IndividuUlr $base)
{
$reflector = new \ReflectionClass($base);
foreach ($reflector->getMethods(\ReflectionMethod::IS_PUBLIC) as $key => $method) {
if (strpos($method->getName(), 'get') === 0) {
$setter = 'set' . substr($method->getName(), 3);
$getter = $method->getName();
if (method_exists($this, $setter) && $base->$getter()) {
$this->$setter($base->$getter());
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment