PHPackages                             tiny-blocks/immutable-object - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [PSR &amp; Standards](/categories/psr-standards)
4. /
5. tiny-blocks/immutable-object

ActiveLibrary[PSR &amp; Standards](/categories/psr-standards)

tiny-blocks/immutable-object
============================

Provides immutable behavior for objects.

1.1.0(4mo ago)314.3k↓14.3%1MITPHPPHP ^8.5CI passing

Since Oct 5Pushed 3mo ago2 watchersCompare

[ Source](https://github.com/tiny-blocks/immutable-object)[ Packagist](https://packagist.org/packages/tiny-blocks/immutable-object)[ Docs](https://github.com/tiny-blocks/immutable-object)[ RSS](/packages/tiny-blocks-immutable-object/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (3)Dependencies (4)Versions (4)Used By (1)

Immutable Object
================

[](#immutable-object)

[![License](https://camo.githubusercontent.com/f8df3091bbe1149f398a5369b2c39e896766f9f6efba3477c63e9b4aa940ef14/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d677265656e)](LICENSE)

- [Overview](#overview)
- [Installation](#installation)
- [How to use](#how-to-use)
- [License](#license)
- [Contributing](#contributing)

Overview
--------

[](#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
------------

[](#installation)

```
composer require tiny-blocks/immutable-object
```

How to use
----------

[](#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

[](#concrete-implementation)

By implementing the `Immutable` interface and using the `Immutability` trait, you can ensure that object properties and elements in collections are immutable.

```
