blob: 4e3a723e96ea2fedd718f92516ab146e8dfd0419 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
<?php
namespace Http\Message\Encoding;
use Psr\Http\Message\StreamInterface;
/**
* Stream decompress (RFC 1950).
*
* @author Joel Wurtz <joel.wurtz@gmail.com>
*/
class DecompressStream extends FilteredStream
{
/**
* @param StreamInterface $stream
* @param int $level
*/
public function __construct(StreamInterface $stream, $level = -1)
{
if (!extension_loaded('zlib')) {
throw new \RuntimeException('The zlib extension must be enabled to use this stream');
}
parent::__construct($stream, ['window' => 15], ['window' => 15, 'level' => $level]);
}
/**
* {@inheritdoc}
*/
protected function readFilter()
{
return 'zlib.inflate';
}
/**
* {@inheritdoc}
*/
protected function writeFilter()
{
return 'zlib.deflate';
}
}
|