public static function createElement($lineData) { try { $anElement = new ScheduleElement($lineData); switch (strtolower(trim($anElement->getType()))) { case TIMER_D: try { $aTimer = new Timer($lineData); return $aTimer; } catch (Exception $e) { // if the line is commented out, make it a comment as it is meant to be. // It is not a a disabled timer. if (!$anElement->isEnabled()) { $anElement->setType(COMMENT_D); return $anElement; } throw $e; } break; case MACRO_D: try { $aMacro = new Macro($lineData); return $aMacro; } catch (Exception $e) { // if the line is commented out, make it a comment as it is meant to be. // It is not a a disabled macro. if (!$anElement->isEnabled()) { $anElement->setType(COMMENT_D); return $anElement; } throw $e; } break; case TRIGGER_D: try { $aTrigger = new Trigger($lineData); return $aTrigger; } catch (Exception $e) { // if the line is commented out, make it a comment as it is meant to be. // It is not a a disabled trigger. if (!$anElement->isEnabled()) { $anElement->setType(COMMENT_D); return $anElement; } throw $e; } break; case CONFIG_D: return $anElement; break; case SECTION_D: return $anElement; break; case COMMENT_D: return $anElement; break; } } catch (Exception $e) { throw $e; } }
} echo "* Test ScheduleElement - macro<br/>"; try { $anElement = new ScheduleElement($macroLine); echo " The return of schedule element getElementLine [" . $anElement->getElementLine() . "]<br/>"; echo " The return of schedule element getType [" . $anElement->getType() . "]<br/>"; echo " The return of Timer element isEnabled [" . $anElement->isEnabled() . "]<br/>"; } catch (Exception $e) { echo " E!: " . $e->getMessage() . "<br/>"; } echo "* Test ScheduleElement - trigger<br/>"; try { $anElement = new ScheduleElement($triggerLine); echo " The return of schedule element getElementLine [" . $anElement->getElementLine() . "]<br/>"; echo " The return of schedule element getType [" . $anElement->getType() . "]<br/>"; echo " The return of Timer element isEnabled [" . $anElement->isEnabled() . "]<br/>"; } catch (Exception $e) { echo " E!: " . $e->getMessage() . "<br/>"; } echo "* Test Timer with passed in line <br/>"; try { $timer = new Timer($testLine); echo " The return of Timer getElementLine [" . $timer->getElementLine() . "]<br/>"; echo " The return of Timer element getType [" . $timer->getType() . "]<br/>"; echo " The return of Timer element isEnabled [" . $timer->isEnabled() . "]<br/>"; } catch (Exception $e) { echo " E!: " . $e->getMessage() . "<br/>"; } echo "* Test Timer with no args <br/>"; try { $timer = new Timer();