chore: complete update
This commit is contained in:
87
.archive/StreamWrapper/Context/StreamContext.php
Normal file
87
.archive/StreamWrapper/Context/StreamContext.php
Normal file
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Archive\StreamWrapper\Context;
|
||||
|
||||
/**
|
||||
* Wrapper für Stream-Context-Optionen
|
||||
*/
|
||||
final class StreamContext
|
||||
{
|
||||
private array $options = [];
|
||||
private array $params = [];
|
||||
|
||||
public function __construct($resource = null)
|
||||
{
|
||||
if ($resource !== null) {
|
||||
$this->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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user