Blame | Letzte Änderung | Log anzeigen | RSS feed
<?php namespace Clockwork\Request;// Data structure representing custom user dataclass UserData{// Data itemsprotected $data = [];// Data titleprotected $title;// Add generic user datapublic function data(array $data, $key = null){if ($key !== null) {return $this->data[$key] = new UserDataItem($data);}return $this->data[] = new UserDataItem($data);}// Add user data shown as counterspublic function counters(array $data){return $this->data($data)->showAs('counters');}// Add user data shown as tablepublic function table($title, array $data){return $this->data($data)->showAs('table')->title($title);}// Set data titlepublic function title($title){$this->title = $title;return $this;}// Transform data and all contents to a serializable array with metadatapublic function toArray(){return array_merge(array_map(function ($data) { return $data->toArray(); }, $this->data),[ '__meta' => array_filter([ 'title' => $this->title ]) ]);}}