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