In my current PHP project I have a number of classes that are pure data-classes, similar what is called POCO in C# world (I omit getters\setters for now):
class MyEntity {
public $id;
public $name;
}
I need to serialize\deserialize such entities in different formats (for example, to/from JSON and XML) and keep serialization detailes out of the classes itself.
For deserialization a Builder pattern seems to be a good choice, but I'm not sure about serialization. I suppose I'm missing something obvious here.
Aucun commentaire:
Enregistrer un commentaire