/** * @param VirtualServerEntity $entity * @param array $entityData * * @return VirtualServerEntity */ private function fillEntityByData(VirtualServerEntity $entity, array $entityData) { $entity->setCpuLimit($entityData['cpuLimit'])->setCpuUnits($entityData['cpuUnits'])->setCpus($entityData['cpus'])->setDailyBackup($entityData['dailyBackup'])->setDescription($entityData['description'])->setDiskSpace($entityData['diskSpace'])->setExpirationDate($entityData['expirationDate'])->setHardwareServerId($entityData['hardwareServerId'])->setHostName($entityData['hostName'])->setId($entityData['id'])->setIdentity($entityData['identity'])->setIpAddress($entityData['ipAddress'])->setMemory($entityData['memory'])->setNameServer($entityData['nameserver'])->setOriginalOSTemplate($entityData['origOSTemplate'])->setOriginalServerTemplate($entityData['origServerTemplate'])->setSearchDomain($entityData['searchDomain'])->setStartOnBoot($entityData['startOnBoot'])->setState($entityData['state'])->setUserId($entityData['userId'])->setVSwap($entityData['vswap']); return $entity; }
/** * @param SimpleXMLElement $serverData * * @return VirtualServerEntity */ private function generateVirtualServerEntity(SimpleXMLElement $serverData) { $server = new VirtualServerEntity(); $server->setCpuLimit($this->isNilProperty($serverData->cpu_limit) ? false : $serverData->cpu_limit)->setCpuUnits($this->isNilProperty($serverData->cpu_units) ? false : $serverData->cpu_units)->setCpus($this->isNilProperty($serverData->cpus) ? false : $serverData->cpus)->setDailyBackup(filter_var((string) $serverData->daily_backup, FILTER_VALIDATE_BOOLEAN))->setDescription($serverData->description)->setDiskSpace((int) $serverData->diskspace)->setExpirationDate($this->isNilProperty($serverData->expiration_date) ? false : date_create_from_format('Y-m-d|', (string) $serverData->expiration_date))->setHardwareServerId((int) $serverData->hardware_server_id)->setHostName($serverData->host_name)->setId((int) $serverData->id)->setIdentity((int) $serverData->identity)->setIpAddress($serverData->ip_address)->setMemory((int) $serverData->memory)->setNameServer($this->isNilProperty($serverData->nameserver) ? false : (string) $serverData->nameserver)->setOriginalOSTemplate($serverData->orig_os_template)->setOriginalServerTemplate($serverData->orig_server_template)->setSearchDomain($this->isNilProperty($serverData->search_domain) ? false : (string) $serverData->search_domain)->setStartOnBoot(filter_var((string) $serverData->start_on_boot, FILTER_VALIDATE_BOOLEAN))->setState((string) $serverData->state)->setUserId($this->isNilProperty($serverData->user_id) ? false : $serverData->user_id)->setVSwap((int) $serverData->vswap); return $server; }