expected_keys as $key) { if (array_key_exists($key, $received)) { $this->$key = $received[$key]; } } } }