dynamic class method call chaining by array values
<p>For example I have class <strong>MyClass</strong>:</p>

<pre><code>Class MyClass {

    public function method_1() {
        return $this;
    }

    public function method_2() {
        return $this;
    }

    public function method_n() {
        return $this;
    }
}
</code></pre>

<p>And I have array of functions and their arguments:</p>

<pre><code>$array = array(
    'method_1' =&gt; array(
        '0' =&gt; 'first_argument',
        '1' =&gt; 'second_argument',
        '2' =&gt; 'nth_argument',
    ),
    'method_2' =&gt; array(
        '0' =&gt; 'first_argument',
        '1' =&gt; 'second_argument',
        '2' =&gt; 'nth_argument',
    ),
);
</code></pre>

<p>How to call <code>MyClass</code> methods from the array in chain?</p>

<pre><code>$result = $my_class-&gt;$array['method_1']($array['method_1'][0], $array['method_1'][0])
    -&gt;$array['method_1']($array['method_2'][0], $array['method_2'][0])
    -&gt;$array['method_n']($array['method_n'][0], $array['method_n'][0]);
</code></pre>

<p>For example:</p>

<pre><code>foreach($array as $function =&gt; $args) {
   // build chain here and execute after foreach
}
</code></pre>

<p>So, main question is how to call unlimited and unknown number of class functions with arguments in chain? Thanks!</p>
