firstname = $firstname; $this->lastname = $lastname; } /** * @PreSerialize */ private function prepareForSerialization() { $this->name = $this->firstname . ' ' . $this->lastname; } /** * @PostSerialize */ private function cleanUpAfterSerialization() { $this->name = null; } /** * @PostDeserialize */ private function afterDeserialization() { [$this->firstname, $this->lastname] = explode(' ', $this->name); $this->name = null; } }