Immutable encapsulations
Immutable ArrayEncapsulation
use Dustin\Encapsulation\ImmutableEncapsulation;
$encapsulation = new ImmutableEncapsulation([
'foo' => 'bar',
'hello' => 'world'
]);
$encapsulation->set('field', 'value'); // Will throw an exceptionImmutability in your own encapsulation
use Dustin\Encapsulation\PropertyEncapsulation;
use Dustin\Encapsulation\ImmutableTrait;
class MyEncapsulation extends PropertyEncapsulation {
use ImmutableTrait;
protected $foo = null;
protected $bar = null;
}
$encapsulation = new MyEncapsulation(['foo' => 'foo']);
$encapsulation->set('bar', 'bar'); // Will throw an exceptionImmutable containers
Last updated