Created
March 26, 2013 10:28
-
-
Save iamdey/5244405 to your computer and use it in GitHub Desktop.
Proxy class creation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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