Darghon Posted August 9, 2012 Share Posted August 9, 2012 Hi all, I'm pretty experience with OOP in PHP, but I'm looking for a good way to solve the next problem: I have a base entity. This entity is saved in a database somewhere and a php object can get filled with it's record data. This entity can have different properties defined with flags. For instance, entity is animal, and a specific animal has the flag "can_fly", so I want the entity to allow flight functions. Other animals might have a flag "can_swim", which invokes swimming functions. Some animals have multiple flags etc... so how can I best set this up, so that I can use record data to construct my object, with all needed functionality? Without having to create 100's of functions in the entity object and checking if the required flag is set or not. so a "extend on demand", or something along those lines. Any other solutions for this problem would be great as well. or tips about a design pattern that might resolves this. i'm reluctant to using stdclass in php, so if possible, I'd like a solution that doesn't build a generic class, or a reflection class. thx in advance Quote Link to comment https://forums.phpfreaks.com/topic/266849-oop-class-building-help/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.