Work with multiple properties of the facility (php)
Well, that's the question. Let's say there's an abstract object of a product with a lot of fields (price, name, etc.) and the fields are allowed to be two dozen. How is it right to work with them and access them? Create a huge collap of hetters? And let's say, in updating the facility in the bud, you need to take all the properties and make an update on a single request? With orm, I'm not very familiar with the task, and the task does not imply its use, but it's not the kind of assignment that I've done, and the question of the organization is how to design the object properly so that it can be convenient to treat its properties and change its image, let's say, in the bud. Thank you!
Alberto last edited by
I'm not familiar with orm, and the task doesn't mean it. Use
I don't know how to put this object in order to make it comfortable. properties and alter his reflection, let's say, in hell.
Read each other in the words of OBD:
You want to write an object in the OBD system, use the ORM There's some rules to work with properties.
If it's just an object in the ranch, watch how you plan to work with him.
In any case, you want to validate the underlying arguments or to organize interactions between the properties (one depending on the other) - provide access to properties through methods. If the object is just a certain state without logic, it's easier to just make public properties.
How to do (getters, setters, magic
ArrayAccess- It's pure taste. If you wish, you can even turn out, for example
__call($name)hang the method
(get|set)SomePropertyand operate on this characteristic, but you lose the code analyser (PhpStorm).
P.S. If the object contains too many properties, it's a reason to wonder if it's all right and there's no point in making a decomposition.