/**
  *
  * @param SimpleXMLElement $elt
  * @return FzRule 
  */
 public static function fromXml(SimpleXMLElement $elt)
 {
     $fzRule = new FzRule();
     $fzRule->setSpeed((int) $elt['Speed']);
     $fzRule->setDays((int) $elt->Days);
     //Date
     if (count($elt->Date)) {
         $date = array();
         $date['Year'] = (string) $elt->Date['Year'];
         $date['Month'] = (string) $elt->Date['Month'];
         $date['Day'] = (string) $elt->Date['Day'];
         $fzRule->setDate($date);
     }
     //From
     if (count($elt->From)) {
         $from = array();
         $from['Hour'] = (string) $elt->From['Hour'];
         $from['Minute'] = (string) $elt->From['Minute'];
         $from['Second'] = (string) $elt->From['Second'];
         $fzRule->setFrom($from);
     }
     //To
     if (count($elt->To)) {
         $to = array();
         $to['Hour'] = (string) $elt->To['Hour'];
         $to['Minute'] = (string) $elt->To['Minute'];
         $to['Second'] = (string) $elt->To['Second'];
         $fzRule->setTo($to);
     }
     return $fzRule;
 }
 /**
  *
  * @param SimpleXMLElement $elt 
  * 
  * @return FzSpeedLimits
  */
 public static function fromXml(SimpleXMLElement $elt)
 {
     $fzSpeedLimit = new FzSpeedLimits();
     $attributes['DlType'] = (string) $elt['DlType'];
     $attributes['DlLimit'] = (string) $elt['DlLimit'];
     $attributes['ServerDlLimitBypass'] = (string) $elt['ServerDlLimitBypass'];
     $attributes['UlType'] = (string) $elt['UlType'];
     $attributes['UlLimit'] = (string) $elt['UlLimit'];
     $attributes['ServerUlLimitBypass'] = (string) $elt['ServerUlLimitBypass'];
     $fzSpeedLimit->setAttributes($attributes);
     $download = array();
     foreach ($elt->Download->Rule as $ruleElt) {
         $download[] = FzRule::fromXml($ruleElt);
     }
     $fzSpeedLimit->setDownload($download);
     $upload = array();
     foreach ($elt->Upload->Rule as $ruleElt) {
         $upload[] = FzRule::fromXml($ruleElt);
     }
     $fzSpeedLimit->setUpload($upload);
     return $fzSpeedLimit;
 }
 public function writeRule(SimpleXMLElement $dl, FzRule $rule)
 {
     $r = $dl->addChild('Rule');
     $r->addAttribute('Speed', $rule->getSpeed());
     $r->addChild('Days', $rule->getDays());
     if ($rule->getDate()) {
         $date = $rule->getDate();
         $dateElt = $r->addChild('Date');
         $dateElt->addAttribute('Year', $date['Year']);
         $dateElt->addAttribute('Month', $date['Month']);
         $dateElt->addAttribute('Day', $date['Day']);
     }
     if (count($rule->getFrom()) > 0) {
         $from = $rule->getFrom();
         $fromElt = $r->addChild('From');
         $fromElt->addAttribute('Year', $from['Hour']);
         $fromElt->addAttribute('Month', $from['Minute']);
         $fromElt->addAttribute('Day', $from['Second']);
     }
     if (count($rule->getTo()) > 0) {
         $to = $rule->getTo();
         $toElt = $r->addChild('To');
         $toElt->addAttribute('Year', $to['Hour']);
         $toElt->addAttribute('Month', $to['Minute']);
         $toElt->addAttribute('Day', $to['Second']);
     }
 }