What is Bag and when to use Value Objects?
mainBag is a library for creating immutable, strongly typed Value Objects in PHP.
When to use them: You should use Bag Value Objects in place of regular associative arrays. This allows you to enforce type safety and immutability, making your data handling safer and more predictable.
Key Features:
- Immutability & Strong Typing: Data cannot be changed after instantiation, and types are strictly enforced.
- Built-in Validation & Casting: Ensures data conforms to expected formats.
- Composability: You can nest Bag value objects and collections to build complex, hierarchical data structures.