$record */ public function __construct(array $record) { $this->averageIncome = $record['average_income'] ?? null; $this->accuracyRadius = $record['accuracy_radius'] ?? null; $this->latitude = $record['latitude'] ?? null; $this->longitude = $record['longitude'] ?? null; $this->metroCode = $record['metro_code'] ?? null; $this->populationDensity = $record['population_density'] ?? null; $this->timeZone = $record['time_zone'] ?? null; } /** * @return array */ public function jsonSerialize(): array { $js = []; if ($this->averageIncome !== null) { $js['average_income'] = $this->averageIncome; } if ($this->accuracyRadius !== null) { $js['accuracy_radius'] = $this->accuracyRadius; } if ($this->latitude !== null) { $js['latitude'] = $this->latitude; } if ($this->longitude !== null) { $js['longitude'] = $this->longitude; } if ($this->metroCode !== null) { $js['metro_code'] = $this->metroCode; } if ($this->populationDensity !== null) { $js['population_density'] = $this->populationDensity; } if ($this->timeZone !== null) { $js['time_zone'] = $this->timeZone; } return $js; } }