Properties Bags

A bag of properties is a simple collection structure with basic tooling for array. It comes in 2 versions:

As the name speak for itself, ImmutablePropertiesBag properties cannot be altered after object creation and will throw an exception if you try to.

A properties bag implement Peak\Blueprint\Collection\Dictionary and JsonSerializable

$bag = new PropertiesBag([
    'foo' => 'bar',
    'name' => 'jane'
]);

Set and Get

// set
$bag->set('name', 'john');
$bar->name = 'john';
$bag['name'] = 'john';

// get
$bag->get('name');
$bag->name;
$bag['name'];

Isset and Unset

// isset
isset($bag->name);
isset($bag['name']);
$bag->has('name');

// unset
unset($bag->name);
unset($bag['name']);

Loop

foreach ($bag as $property => $value) {
    // ...
}

Other methods

Bag also support: