Image.php 900 Bytes
Newer Older
1 2 3 4 5 6 7 8
<?hh // strict

namespace _91Carriage\Droplets;

use ConstMapAccess;
use InvalidArgumentException as IAE;

class Image extends Object {
Simon Welsh's avatar
Simon Welsh committed
9 10 11 12 13 14 15
	public int $id;
	public string $name;
	public string $distribution;
	public ?string $slug;
	public bool $public;
	public Set<string> $regions;
	public int $min_disk_size;
16 17

	public function __construct(ConstMapAccess<string, mixed> $data) {
18 19 20 21 22 23 24 25 26 27 28 29 30
		$this->id = nullthrows(static::_toInt($data, 'id'));
		$this->name = nullthrows(static::_toString($data, 'name'));
		$this->distribution = nullthrows(static::_toString($data,
			'distribution'));
		$this->slug = static::_toString($data, 'slug', false);
		$this->public = nullthrows(static::_toBool($data, 'public'));
		$this->regions = nullthrows(static::_toSet(
			$data,
			'regions',
			class_meth(static::class, '_toString'),
		));
		$this->min_disk_size = nullthrows(static::_toInt($data,
			'min_disk_size'));
31 32
	}
}