cleanup context handling for wrappers

This commit is contained in:
Robin Appelman 2019-03-11 16:52:13 +01:00
commit 2c8ae56d02
16 changed files with 182 additions and 258 deletions

View file

@ -63,17 +63,14 @@ class CountWrapper extends Wrapper {
if (!is_callable($callback)) {
throw new \InvalidArgumentException('Invalid or missing callback');
}
$context = stream_context_create(array(
'count' => array(
'source' => $source,
'callback' => $callback
)
));
return self::wrapSource($source, $context);
return self::wrapSource($source, [
'source' => $source,
'callback' => $callback
]);
}
protected function open() {
$context = $this->loadContext('count');
$context = $this->loadContext();
$this->callback = $context['callback'];
return true;
}