Code Duplication    Length = 21-27 lines in 4 locations

src/Encoding/CompressStream.php 1 location

@@ 12-32 (lines=21) @@
9
 *
10
 * @author Joel Wurtz <[email protected]>
11
 */
12
class CompressStream extends FilteredStream
13
{
14
    public function __construct(StreamInterface $stream, $level = -1)
15
    {
16
        if (!extension_loaded('zlib')) {
17
            throw new \RuntimeException('The zlib extension must be enabled to use this stream');
18
        }
19
20
        parent::__construct($stream, ['window' => 15, 'level' => $level], ['window' => 15]);
21
    }
22
23
    public function getReadFilter()
24
    {
25
        return 'zlib.deflate';
26
    }
27
28
    public function getWriteFilter()
29
    {
30
        return 'zlib.inflate';
31
    }
32
}
33

src/Encoding/DecompressStream.php 1 location

@@ 12-32 (lines=21) @@
9
 *
10
 * @author Joel Wurtz <[email protected]>
11
 */
12
class DecompressStream extends FilteredStream
13
{
14
    public function __construct(StreamInterface $stream, $level = -1)
15
    {
16
        if (!extension_loaded('zlib')) {
17
            throw new \RuntimeException('The zlib extension must be enabled to use this stream');
18
        }
19
20
        parent::__construct($stream, ['window' => 15], ['window' => 15, 'level' => $level]);
21
    }
22
23
    public function getReadFilter()
24
    {
25
        return 'zlib.inflate';
26
    }
27
28
    public function getWriteFilter()
29
    {
30
        return 'zlib.deflate';
31
    }
32
}
33

src/Encoding/GzipDecodeStream.php 1 location

@@ 12-32 (lines=21) @@
9
 *
10
 * @author Joel Wurtz <[email protected]>
11
 */
12
class GzipDecodeStream extends FilteredStream
13
{
14
    public function __construct(StreamInterface $stream, $level = -1)
15
    {
16
        if (!extension_loaded('zlib')) {
17
            throw new \RuntimeException('The zlib extension must be enabled to use this stream');
18
        }
19
20
        parent::__construct($stream, ['window' => 31], ['window' => 31, 'level' => $level]);
21
    }
22
23
    public function getReadFilter()
24
    {
25
        return 'zlib.inflate';
26
    }
27
28
    public function getWriteFilter()
29
    {
30
        return 'zlib.deflate';
31
    }
32
}
33

src/Encoding/GzipEncodeStream.php 1 location

@@ 12-38 (lines=27) @@
9
 *
10
 * @author Joel Wurtz <[email protected]>
11
 */
12
class GzipEncodeStream extends FilteredStream
13
{
14
    public function __construct(StreamInterface $stream, $level = -1)
15
    {
16
        if (!extension_loaded('zlib')) {
17
            throw new \RuntimeException('The zlib extension must be enabled to use this stream');
18
        }
19
20
        parent::__construct($stream, ['window' => 31, 'level' => $level], ['window' => 31]);
21
    }
22
23
    /**
24
     * {@inheritdoc}
25
     */
26
    public function getReadFilter()
27
    {
28
        return 'zlib.deflate';
29
    }
30
31
    /**
32
     * {@inheritdoc}
33
     */
34
    public function getWriteFilter()
35
    {
36
        return 'zlib.inflate';
37
    }
38
}
39