streamContext = StreamWrapperHelper::initializeContext($this->context); $this->parsedUrl = StreamWrapperHelper::parseUrl($path); $this->mode = $mode; $this->source = $this->parsedUrl['host'] ?: 'default'; $this->configKey = $this->parsedUrl['path']; // Config-Manager initialisieren $this->config = new ConfigManager(); // Konfigurationswert laden if (str_contains($mode, 'r') || str_contains($mode, '+')) { $this->content = $this->loadContent($this->configKey); } return true; } public function stream_read(int $count): string|false { return StreamWrapperHelper::streamRead($this->content, $this->position, $count); } public function stream_write(string $data): int|false { return StreamWrapperHelper::streamWrite($this->content, $this->position, $data); } public function stream_tell(): int|false { return $this->position; } public function stream_eof(): bool { return $this->position >= strlen($this->content); } public function stream_seek(int $offset, int $whence = SEEK_SET): bool { return StreamWrapperHelper::streamSeek($this->content, $this->position, $offset, $whence); } public function stream_close(): void { $this->content = ''; $this->position = 0; } public function stream_stat(): array|false { return StreamWrapperHelper::streamStat($this->content); } public function url_stat(string $path, int $flags): array|false { $parsedUrl = StreamWrapperHelper::parseUrl($path); $source = $parsedUrl['host'] ?: 'default'; $configKey = $parsedUrl['path']; $config = new ConfigManager(); if (!$config->has($configKey)) { return false; } $value = $config->get($configKey); $content = is_string($value) ? $value : json_encode($value); $size = strlen($content); return StreamWrapperHelper::createDefaultStat($size); } // Nicht unterstützte Operationen public function mkdir(string $path, int $mode, int $options): bool { return false; } public function rmdir(string $path, int $options): bool { return false; } public function dir_opendir(string $path, int $options): bool { return false; } public function dir_readdir(): string|false { return false; } public function dir_rewinddir(): bool { return false; } public function dir_closedir(): bool { return false; } public function rename(string $path_from, string $path_to): bool { return false; } public function unlink(string $path): bool { return false; } private function loadContent(string $path): string { $value = $this->config->get($path); if ($value === null) { return ''; } return is_string($value) ? $value : json_encode($value); } }