lundi 23 mars 2015

Better way of manipulating large objects


I am doing a lot of work with SOAP Api in PHP and the objects that are returned are quite big. I am then updating the objects from local db changes and pushing them back.


So more often than not I have a large object returned from a db query and a large object retrieved from a SOAP call and I have to update the one from the other.


So I end up with a lot of this:



$api_object->Organisation->Location[0]->AddressLine1 = $db_object->MainAddress->address_line_1;
$api_object->Organisation->Location[0]->AddressLine2 = $db_object->MainAddress->address_line_2;

$api_object->Organisation->Location[1]->AddressLine1 = $db_object->SecondaryAddress->address_line_1;
$api_object->Organisation->Location[1]->AddressLine2 = $db_object->SecondaryAddress->address_line_2;


And so on, and so on with many more elements! And as you can see the names of the fields don't often match in naming or depth.


I just wondered if anyone had any suggestions how to do it better.





Aucun commentaire:

Enregistrer un commentaire