class C extends A class and B class , how optimize the code

Wednesday, July 9, 2014

I have two classes A and B. Class C may be extends A and B. I need to do it optimally.



class A {
public function testA() {
echo "this is function testA \n";
}
}

class B {
public function testB() {
echo "this is function testB \n";
}
}

class C extends A {
public function __call($method, $args){
$this->b =new B();
try {
return !method_exists ($this->b , $method ) || !$this->b->$method($args[0]);
} catch(Exception $e) {
echo "error";
}
}
}

$object = new C();
$object->testA();
$object->testB();
$object->testD();


How I can optimize this code?







http://ift.tt/1kCW544