Commit b6eb90f6 authored by Simon Welsh's avatar Simon Welsh

Correct detection of the ipv4/ipv6 values

parent 97aa788c
......@@ -126,25 +126,37 @@ class Droplet extends Object {
} else {
throw new IAE('A size value is required');
}
if (!$data->containsKey('networks')) {
throw new IAE('A networks object is required');
}
$networks = $data->at('networks');
if (is_object($networks)) {
$networks = get_object_vars($networks);
}
if (is_array($networks)) {
$networks = new Map($networks);
} else {
throw new IAE('Expected a map for key networks');
}
// ipv4
if ($data->containsKey('ipv4')) {
if ($networks->containsKey('v4')) {
$this->ipv4 = static::_toVector(
$data->at('ipv4'),
'ipv4',
$networks->at('v4'),
'v4',
class_meth(static::class, '_toNetwork'),
);
} else {
throw new IAE('An ipv4 value is required');
throw new IAE('An v4 value is required');
}
// ipv6
if ($data->containsKey('ipv6')) {
if ($networks->containsKey('v6')) {
$this->ipv6 = static::_toVector(
$data->at('ipv6'),
'ipv6',
$networks->at('v6'),
'v6',
class_meth(static::class, '_toNetwork'),
);
} else {
throw new IAE('An ipv6 value is required');
throw new IAE('An v6 value is required');
}
// kernel
if ($data->containsKey('kernel')) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment