/**
  * @param \stdClass|array $parameters
  */
 public function build($parameters)
 {
     foreach ($parameters as $property => $value) {
         $property = \DigitalOceanV2\convert_to_camel_case($property);
         $this->{$property} = $value;
     }
 }
Ejemplo n.º 2
0
 /**
  * @param \stdClass|array $parameters
  */
 public function build($parameters)
 {
     foreach ($parameters as $property => $value) {
         switch ($property) {
             case 'networks':
                 if (is_object($value)) {
                     if (property_exists($value, 'v4')) {
                         foreach ($value->v4 as $subProperty => $subValue) {
                             $this->networks[] = new Network($subValue);
                         }
                     }
                     if (property_exists($value, 'v6')) {
                         foreach ($value->v6 as $subProperty => $subValue) {
                             $this->networks[] = new Network($subValue);
                         }
                     }
                 }
                 break;
             case 'kernel':
                 if (is_object($value)) {
                     $this->kernel = new Kernel($value);
                 }
                 break;
             case 'size':
                 if (is_object($value)) {
                     $this->size = new Size($value);
                 }
                 break;
             case 'region':
                 if (is_object($value)) {
                     $this->region = new Region($value);
                 }
                 break;
             case 'image':
                 if (is_object($value)) {
                     $this->image = new Image($value);
                 }
                 break;
             case 'next_backup_window':
                 $this->nextBackupWindow = new NextBackupWindow($value);
                 break;
             default:
                 $this->{\DigitalOceanV2\convert_to_camel_case($property)} = $value;
         }
     }
     if (is_array($this->features) && count($this->features)) {
         $this->backupsEnabled = in_array("backups", $this->features);
         $this->virtIOEnabled = in_array("virtio", $this->features);
         $this->privateNetworkingEnabled = in_array("private_networking", $this->features);
         $this->ipv6Enabled = in_array("ipv6", $this->features);
     }
 }