Completed
Push — master ( a25286...dbbded )
by Márk
02:51 queued 49s
created

GzipEncodeStream::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 8
Ratio 100 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 2
Bugs 0 Features 2
Metric Value
c 2
b 0
f 2
dl 8
loc 8
ccs 5
cts 5
cp 1
rs 9.4286
cc 2
eloc 4
nc 2
nop 2
crap 2
1
<?php
2
3
namespace Http\Message\Encoding;
4
5
use Psr\Http\Message\StreamInterface;
6
7
/**
8
 * Stream for encoding to gzip format (RFC 1952).
9
 *
10
 * @author Joel Wurtz <[email protected]>
11
 */
12 View Code Duplication
class GzipEncodeStream extends FilteredStream
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

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