PHP OOP Programming - How To Apply
<p>Hi I'm trying to move away from procedural programming and at the same time have a better appreciation for design patterns. I would like to know what Design Pattern can best represent the code below. It's an if else statement that basically outputs a value based on the time of day. This is just a sample of several if/else if statement I have in the code. Which OOP Pattern is appropriate (Iterator, Singleton, Factory.. )?</p>

<pre><code>if($dayval == "Sun" &amp;&amp; $date &gt;= 0 &amp;&amp; $date &lt; 18) {
    $timemax = 18;
    $timeleft = ($timemax - $date);
    if($timeleft == 1) {
        $arr = array('tstatus' =&gt; 'Trading begins today at 6:00pm (less than '. $timeleft. ' hour to go) -  have a great trade week!',
                     'tcode'   =&gt; 'closed');                         
    }
    else {
        $arr = array('tstatus' =&gt; 'Trading begins today at 6:00pm (less than ' .$timeleft. ' hours to go) -  have a great trade week!',
                     'tcode'   =&gt; 'closed'                       
        );          
    }
    echo json_encode($arr);
}

else if($dayval == "Sun" &amp;&amp; $date &gt;= 18 &amp;&amp; $date &lt; 19) {
    $timemax = 19;
    $timeleft = ($timemax - $date);
    if($timeleft == 1) {
        $arr = array('tstatus' =&gt; 'Asian Market opening in less than ' .$timeleft. ' hour',
                     'tcode'   =&gt; 'closed');                         
    }
    else {
        $arr = array('tstatus' =&gt; 'Asian Market opening in less than ' .$timeleft. ' hours',
                     'tcode'   =&gt; 'closed'                       
        );          
    }
    echo json_encode($arr);
</code></pre>
