for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/*
* This file is part of Graze DataStructure
*
* Copyright (c) 2017 Nature Delivered Ltd. <http://graze.com>
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
* @see http://github.com/graze/data-structure/blob/master/LICENSE
* @link http://github.com/graze/data-structure
*/
namespace Graze\DataStructure\Container;
/**
* ImmutableFlatContainer can access data in child arrays and containers, any modification is immutable
* (for the top level) but can modify child containers
* ```php
* $container = new ImmutableFlatContainer(['a'=>'b']);
* $new = $container->set('c', 'd');
* $container->getAll();
* // ['a' => 'b']
* $new->getAll()
* // ['a' => 'b', 'c' => 'd']
* $child = new Container(['a' => 'b']);
* $container = new ImmutableFlatContainer([
* ```
class ImmutableFlatContainer extends FlatContainer
{
* @param array $params
public function __construct(array $params = [])
parent::__construct([]);
foreach ($params as $key => $value) {
$this->doSet($key, $value);
}
* @param string $key
* @param mixed $value
* @return ContainerInterface
public function set($key, $value)
$cont = clone $this;
$cont->doSet($key, $value);
return $cont;
public function remove($key)
if ($this->has($key)) {
$cont->doRemove($key);
return $this;