Skip to content
Rieks Visser edited this page Sep 5, 2017 · 3 revisions

Data Container

This package provides a data container. A data container can contain any data. The data can be accessed using a dot-notation path. An example:

<?php
/** @var Mediact\DataContainer\DataContainer $container */
// Set data on the container.
$container->set('mydata.foo', ['value' => 'Foo']);
// Get data from the container.
$container->get('mydata.foo.value');                 

Data container operations

The data container supports the following operations:

  • has() determines if the data container has data set for a given path.
  • get() returns data for a given path.
  • set() set data for a given path.
  • glob() return a list of paths that match a given pattern.
  • expand() method returns a list of paths that match the given pattern and also returns their replacements.
  • branch() returns the paths that are matched by a pattern as a list of data containers.
  • node() returns a single container with the data from a path.
  • copy() for copying data.
  • move() for moving data.

Decorators

Data container supports decorators:

  • Decorators of a data container can be created using DataContainerDecoratorTrait.
  • A decorator that is also traversable can be created with DataContainerIteratorAggregateTrait.
Clone this wiki locally