$raw * @param list $locales */ public function __construct(array $raw, array $locales = ['en']) { $this->continent = new Continent( $raw['continent'] ?? [], $locales ); $this->country = new CountryRecord( $raw['country'] ?? [], $locales ); $this->maxmind = new MaxMind($raw['maxmind'] ?? []); $this->registeredCountry = new CountryRecord( $raw['registered_country'] ?? [], $locales ); $this->representedCountry = new RepresentedCountry( $raw['represented_country'] ?? [], $locales ); $this->traits = new Traits($raw['traits'] ?? []); } /** * @return array|null */ public function jsonSerialize(): ?array { $js = []; $continent = $this->continent->jsonSerialize(); if (!empty($continent)) { $js['continent'] = $continent; } $country = $this->country->jsonSerialize(); if (!empty($country)) { $js['country'] = $country; } $maxmind = $this->maxmind->jsonSerialize(); if (!empty($maxmind)) { $js['maxmind'] = $maxmind; } $registeredCountry = $this->registeredCountry->jsonSerialize(); if (!empty($registeredCountry)) { $js['registered_country'] = $registeredCountry; } $representedCountry = $this->representedCountry->jsonSerialize(); if (!empty($representedCountry)) { $js['represented_country'] = $representedCountry; } $traits = $this->traits->jsonSerialize(); if (!empty($traits)) { $js['traits'] = $traits; } return $js; } }