public function fromXML(SimpleXMLElement $xml) { $loadBalancing = new LoadBalancing(); $loadBalancing->setType((string) $xml['type']); $loadBalancing->setTargetHealthCheck((string) $xml->targetHealthCheck[type]); if (!empty($xml->failOver)) { $loadBalancing->setFailOver(true); $onResponseCode = array(); foreach ($xml->failOver->onResponseCode as $responsCode) { $onResponseCode[] = (string) $responsCode; } $loadBalancing->setOnResponseCode($onResponseCode); } return $loadBalancing; }
public static function fromXML(SimpleXMLElement $xml) { $context = new ApiContext(); $context->setDefault($xml['default'] == "true"); $context->setId((string) $xml['id']); $context->setStatus(Status::fromXML($xml->status)); $context->setMaxRateLimitTPMThreshold((int) $xml->maxRateLimitTPMThreshold); $context->setMaxRateLimitTPMWarning((int) $xml->maxRateLimitTPMWarning); $context->setMaxRateLimitTPSThreshold((int) $xml->maxRateLimitTPSThreshold); $context->setMaxRateLimitTPSWarning((int) $xml->maxRateLimitTPSWarning); if (!empty($xml->loadBalancing)) { $context->setLoadBalancing(LoadBalancing::fromXML($xml->loadBalancing)); } $ths = array(); foreach ($xml->targetHosts->targetHost as $targetHostXML) { $targetHost = TargetHost::fromXML($targetHostXML); $ths[] = $targetHost; } $context->setTargetHosts($ths); return $context; }