Download the PHP package tiny-blocks/immutable-object without Composer
On this page you can find all versions of the php package tiny-blocks/immutable-object. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download tiny-blocks/immutable-object
More information about tiny-blocks/immutable-object
Files in tiny-blocks/immutable-object
Package immutable-object
Short Description Provides immutable behavior for objects.
License MIT
Homepage https://github.com/tiny-blocks/immutable-object
Informations about the package immutable-object
Immutable Object
- Overview
- Installation
- How to use
- License
- Contributing
Overview
The Immutable Object library ensures that objects implementing it remain immutable after initialization. Once created, the state of the object cannot be modified. Any attempt to change properties or collection elements will throw an exception.
Installation
How to use
The library provides the Immutable
interface and the Immutability
trait to guarantee immutability. These components
prevent properties and collections from being modified or unset.
Concrete implementation
By implementing the Immutable
interface and using the Immutability
trait, you can ensure that object properties and
elements in collections are immutable.
Handling property immutability
The Immutability trait also prevents modifications to properties of an object. Trying to modify a property after the object is initialized will throw an exception.
Handling collection immutability
The Immutability
trait also prevents the modification of collection elements (e.g., arrays). Trying to modify or
remove an element will throw an exception.
License
Immutable Object is licensed under MIT.
Contributing
Please follow the contributing guidelines to contribute to the project.