[], 'data' => []]; public function init(array $providerConfig): bool { return true; } public function getIndex(): array { return $this->data['index']; } public function getItem(string $key) { if (!in_array($key, $this->data['index'])) return null; return $this->data['data'][$key]['data']; } public function getItemMeta(string $key): ?array { if (!in_array($key, $this->data['index'])) return null; return $this->data['data'][$key]['meta']; } public function getItems(array $keys = []): array { $output = []; foreach ($keys as $key) $output[$key] = $this->getItem($key); return $output; } public function hasItem(string $key): bool { return in_array($key, $this->data['index']); } public function clear(): bool { return $this->deleteItems($this->getIndex()); } public function deleteItem(string $key): bool { // Remove the index if (($k = array_search($key, $this->data['index'])) !== false) { unset($this->data['index'][$k]); } // And remove the data unset($this->data['data'][$key]); return true; } public function deleteItems(array $keys): bool { foreach ($keys as $key) $this->deleteItem($key); return true; } public function save(string $key, $value, array $metaData = []): bool { if (!in_array($key, $this->data['index'])) $this->data['index'][] = $key; $this->data['data'][$key] = ['data' => $value, 'meta' => $metaData]; return true; } }