Basics
Create an object
use Dustin\Encapsulation\Encapsulation;
$encapsulation = new Encapsulation();$encapsulation = new Encapsulation([
'foo' => $foo,
'bar' => $bar
]);Setting values
Setting a single value to a field
$encapsulation->set('foo', $foo);
//or
$encapsulation['foo'] = $foo;Unsetting a value
$encapsulation->unset('foo');
//or
unset($encapsulation['foo']);Setting several values
Adding a value to a collection
Adding several values to a collection
Getting values
Get a single value
Getting several values as associative array
Getting all values as associative array
More
Check if a field exists
Get an array of all fields
Check if an object has values
Iterate over all fields
Cloning
Last updated