dustin/encapsulation
A simple way to accommodate, exchange and structorize data with objects
Last updated
A simple way to accommodate, exchange and structorize data with objects
Last updated
dustin/encapsulation is a simple but powerful utility for working with objects and arrays. The main idea is to simplify data handling, structorizing, data exchange between objects, data accomodation and data extraction from objects.
Developing your data objects with encapsulations brings a lot of advantages:
Initialize an object with data in the constructor
Flexible setting and getting values with field name as string
Access multiple field values at once
Add items to arrays
List all fields of an object
Convert an object into an array
Using an object like an array
Iterate over all fields of an object
...
dustin/encapsulation is freely available on packagist. If you do not know how to use composer read the guide at here:
Run the following command within your project directory to add the package as composer dependency. The command assumes you have composer installed globally.
Now composer should have added the newest version of dustin/encapsulation to your composer.json file like this:
An encapsulation is an object which holds key-based data. They consist of three different types which are able to exchange data among each other or to the outside.
They hold their data in an array. You are able to deal with data in an object without declaring properties.
Inheriting from PropertyEncapsulation allows creating normal objects and their properties with the ability to harness all advantages of an encapsulation.
A container holds a list of elements and brings a lot of functions to access and modify these elements. A container does not take care of keys.
Watch the changelog here:
Or get started with using encapsulations: