Define Class Helper Class To Check The Method Existance

 
    <?php
class A {
    function getA( ) {
        return array( "A", "B" );
    }
}class Helper {
    private $classA;    function __construct( A $classA ) {
        $this->classA = $classA;
    }    function __call( $method, $args ) {
        if ( method_exists( $this->classA, $method ) ) {
            return $this->classA->$method( );
        }
    }
}$tool= new Helper( new A() );
print_r( $tool->getA() );
?>

Enjoyed this post? Share it!

 

Leave a comment

Your email address will not be published.