public function __construct(array $definition)
{
// Validate the presence of required properties.
$requiredProperties = ['country_code', 'code', 'name'];
foreach ($requiredProperties as $requiredProperty) {
if (empty($definition[$requiredProperty])) {
throw new \InvalidArgumentException(sprintf('Missing required property %s.', $requiredProperty));
}
}
// Add defaults for properties that are allowed to be empty.
$definition += ['parent' => null, 'locale' => null, 'local_code' => null, 'local_name' => null, 'iso_code' => [], 'postal_code_pattern' => null, 'postal_code_pattern_type' => PatternType::getDefault(), 'children' => new ArrayCollection()];
$this->parent = $definition['parent'];
$this->countryCode = $definition['country_code'];
$this->locale = $definition['locale'];
$this->code = $definition['code'];
$this->localCode = $definition['local_code'];
$this->name = $definition['name'];
$this->localName = $definition['local_name'];
$this->isoCode = $definition['iso_code'];
$this->postalCodePattern = $definition['postal_code_pattern'];
$this->postalCodePatternType = $definition['postal_code_pattern_type'];
$this->children = $definition['children'];
}