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.. )?
if($dayval == "Sun" && $date >= 0 && $date < 18) {
$timemax = 18;
$timeleft = ($timemax - $date);
if($timeleft == 1) {
$arr = array('tstatus' => 'Trading begins today at 6:00pm (less than '. $timeleft. ' hour to go) - have a great trade week!',
'tcode' => 'closed');
}
else {
$arr = array('tstatus' => 'Trading begins today at 6:00pm (less than ' .$timeleft. ' hours to go) - have a great trade week!',
'tcode' => 'closed'
);
}
echo json_encode($arr);
}
else if($dayval == "Sun" && $date >= 18 && $date < 19) {
$timemax = 19;
$timeleft = ($timemax - $date);
if($timeleft == 1) {
$arr = array('tstatus' => 'Asian Market opening in less than ' .$timeleft. ' hour',
'tcode' => 'closed');
}
else {
$arr = array('tstatus' => 'Asian Market opening in less than ' .$timeleft. ' hours',
'tcode' => 'closed'
);
}
echo json_encode($arr);