options = stream_context_get_options($resource); $this->params = stream_context_get_params($resource); } } /** * Gibt eine Option für das angegebene Protokoll zurück */ public function getOption(string $protocol, string $key, $default = null) { return $this->options[$protocol][$key] ?? $default; } /** * Gibt alle Optionen für ein Protokoll zurück */ public function getProtocolOptions(string $protocol): array { return $this->options[$protocol] ?? []; } /** * Setzt eine Option für das angegebene Protokoll */ public function setOption(string $protocol, string $key, $value): self { $this->options[$protocol][$key] = $value; return $this; } /** * Gibt einen Parameter zurück */ public function getParam(string $key, $default = null) { return $this->params[$key] ?? $default; } /** * Setzt einen Parameter */ public function setParam(string $key, $value): self { $this->params[$key] = $value; return $this; } /** * Gibt alle Optionen zurück */ public function getAllOptions(): array { return $this->options; } /** * Gibt alle Parameter zurück */ public function getAllParams(): array { return $this->params; } /** * Erstellt einen neuen Stream-Context mit den aktuellen Optionen */ public function createResource() { return stream_context_create($this->options, $this->params); } }