/** * Merges two user detail value objects * * @param UserDetails $established * @param UserDetails $patch * * @return UserDetails */ public static function mergeProfileData(UserDetails $established, UserDetails $patch) { // since the current business behavior does not allow the change of email addresses // or the registration date, these values are immutable return new self($established->getEmail(), $patch->getLastAction(), $established->getRegistrationDate(), $patch->getLocale() ?: $established->getLocale(), $patch->getRealName() ?: $established->getRealName(), $patch->isLocked()); }