'totalAmount', 'first' => 'firstName', 'last' => 'lastName', 'email' => 'donorEmail', 'userId' => 'wpUserId', 'gateway' => 'paymentGateway', ]; $array = ArrayDataSet::renameKeys( $array, $renameTo ); $expectedKeys = [ 'formId', 'totalAmount', 'firstName', 'email', 'gateway' ]; if ( ! ArrayDataSet::hasRequiredKeys( $array, $expectedKeys ) ) { throw new InvalidArgumentException( 'Invalid FormEntries object, must have the exact following keys: ' . implode( ', ', $expectedKeys ) ); } $formEntries = new self(); foreach ( $array as $key => $value ) { $formEntries->{$key} = $value; } return $formEntries; } }