| 1 | <?php |
||
| 7 | class DataLayer |
||
| 8 | { |
||
| 9 | /** |
||
| 10 | * @var array |
||
| 11 | */ |
||
| 12 | protected $data; |
||
| 13 | |||
| 14 | public function __construct($data = []) |
||
| 18 | |||
| 19 | /** |
||
| 20 | * Add data to the data layer. Supports dot notation. |
||
| 21 | * Inspired by laravel's config repository class. |
||
| 22 | * |
||
| 23 | * @param array|string $key |
||
| 24 | * @param mixed $value |
||
| 25 | */ |
||
| 26 | public function set($key, $value = null) |
||
| 38 | |||
| 39 | /** |
||
| 40 | * Empty the data layer. |
||
| 41 | */ |
||
| 42 | public function clear() |
||
| 46 | |||
| 47 | /** |
||
| 48 | * Return an array representation of the data layer. |
||
| 49 | * |
||
| 50 | * @return array |
||
| 51 | */ |
||
| 52 | public function toArray() |
||
| 56 | |||
| 57 | /** |
||
| 58 | * Return a json representation of the data layer. |
||
| 59 | * |
||
| 60 | * @return string |
||
| 61 | */ |
||
| 62 | public function toJson() |
||
| 66 | } |
||
| 67 |