Suppose there is a class called "Class_A
", it has a member function called "func
".
I want the "func
" to do some extra work by wrapping Class_A
in a decorator class.
$worker = new Decorator(new Original());
Can someone give an example? I've never used OO with PHP.
Is the following version right?
class Decorator
{
protected $jobs2do;
public function __construct($string) {
$this->jobs2do[] = $this->do;
}
public function do() {
// ...
}
}
The above code intends to put some extra work to a array.