Everything in it’s right place
Look at this code, it’s about value objects in PHP
Thanks to type safety through value objects we can make certain guarantees about our data in our code, those guarantees include the existence of a property and the type of any property on the article value object.
Benefits:
- Type based validation
- Guaranteed data structure
- Data grouping allows for smaller function signatures later on
Cons:
- Writing ->props[$foo] is annoying, this can be mitigated with __get() and __set() but I like to keep ->props as a signal that I am reading a value object
Here is a link (not created or associated with me) that confirms my own dogma http://www.phpvalueobjects.info/
Ps - A value object is essentially your own data type of your domain data do not add logic to the class when you need logic, add functions that operate on the data by copy.
Ps Ps — you like reading? you could read this! https://medium.com/@sfyire/filtering-reality-d49f3d8cd23d#.y9om42p9s