title: add methods on the fly to stdClass object
body: <p>I want to add a function on an object that returns a specific value from that object.</p>
  
  <p>I have the following code now:</p>
  
  <pre><code>    &lt;?php
  namespace sdk;
  use core\Sdk;
  
  class Contents extends Sdk {
  
      public $url;
      public $id;
  
      public function __call($method, $args) {
          if (isset($this-&gt;$method)) {
              $func = $this-&gt;$method;
              return call_user_func_array($func, $args);
          }
      }
  
      public function getContents($id = '') {
          $request = 'contents/list/'.$id;
          return $this-&gt;getRequest($request);
      }//getContents
  
      public function getContent($id) {
          $request = 'contents/detail/'.$id;
          $this-&gt;object = $this-&gt;getRequest($request);
          $this-&gt;object-&gt;getItemAttribute = function($attribute) {
              var_dump($this-&gt;object);
          };
          return $this-&gt;object;
      }//getContent
  
  }//Class Contents
  </code></pre>
  
  <p>and I try to start the method via tis code</p>
  
  <pre><code>$contents-&gt;getContent(1);
  $contents-&gt;object-&gt;getItemAttribute('titel');
  </code></pre>
  
  <p>But I keep getting the error "undefined method"</p>
  
  <p>What am I doing wrong?</p>