예제 #1
0
 public static function fromXML(SimpleXMLElement $xml)
 {
     $th = new TargetHost();
     $th->setAuthentication(Authentication::fromXML($xml->authentication));
     $th->setUrl((string) $xml->url);
     $th->setSite((string) $xml->site);
     if ($xml->forwardProxy) {
         $th->setProxy(ForwardProxy::fromXML($xml->forwardProxy));
     }
     if ($xml->connectionParameters) {
         $th->setConnectionParameters(ConnectionParameters::fromXML($xml->connectionParameters));
     }
     return $th;
 }
예제 #2
0
 public function testMultipleHosts()
 {
     $this->assertEquals(['localhost:27017,localhost:27018,localhost', 'db_name', ['replicaSet' => 'rs']], TargetHost::parse("mongodb://localhost:27017,localhost:27018,localhost/db_name?replicaSet=rs"));
 }
예제 #3
0
 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;
 }