Reputation: 11
Does it make sense call a configuration class of Value Object design pattern? For example: I will create a php class that stores database config (db, username, password, host, etc...). This class just returns its values and its values are imutable (unless you edit the file with a text editor :). Is it a Value Object? I've read about Value Object and I want to understand it. Thank you.
Upvotes: 1
Views: 330
Reputation: 145512
Yes, it sort of is. (Though value objects are more purposed for object messaging.)
But it's important to keep in mind that this is one of the design patterns which was intended for languages without PHPs capabilities. It's a workaround for the lack of hash arrays. And that's what you actually should be using here. A good old boring data array.
If you really need to make it immutable (I doubt there is a real point in that), then you can make it so by later wrapping it into an ArrayObject with simply the offsetSet and Unset methods annulled.
Upvotes: 1