DecompressStream::__construct()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 4
nc 2
nop 2
dl 0
loc 10
ccs 4
cts 4
cp 1
crap 2
rs 10
c 1
b 0
f 0
1
<?php
2
3
namespace Http\Message\Encoding;
4
5
use Clue\StreamFilter as Filter;
6
use Psr\Http\Message\StreamInterface;
7
8
/**
9
 * Stream decompress (RFC 1950).
10
 *
11
 * @author Joel Wurtz <[email protected]>
12
 */
13
class DecompressStream extends FilteredStream
14
{
15
    /**
16
     * @param int $level
17
     */
18
    public function __construct(StreamInterface $stream, $level = -1)
19 6
    {
20
        if (!extension_loaded('zlib')) {
21 6
            throw new \RuntimeException('The zlib extension must be enabled to use this stream');
22 1
        }
23
24
        parent::__construct($stream, ['window' => 15]);
25 5
26
        // @deprecated will be removed in 2.0
27
        $this->writeFilterCallback = Filter\fun($this->writeFilter(), ['window' => 15, 'level' => $level]);
0 ignored issues
show
Deprecated Code introduced by
The property Http\Message\Encoding\Fi...m::$writeFilterCallback has been deprecated: since version 1.5, will be removed in 2.0 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

27
        /** @scrutinizer ignore-deprecated */ $this->writeFilterCallback = Filter\fun($this->writeFilter(), ['window' => 15, 'level' => $level]);

This property has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.

Loading history...
Bug introduced by
The function fun was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

27
        $this->writeFilterCallback = /** @scrutinizer ignore-call */ Filter\fun($this->writeFilter(), ['window' => 15, 'level' => $level]);
Loading history...
28 5
    }
29 5
30
    /**
31
     * {@inheritdoc}
32
     */
33
    protected function readFilter()
34 5
    {
35
        return 'zlib.inflate';
36 5
    }
37
38
    /**
39
     * {@inheritdoc}
40
     */
41
    protected function writeFilter()
42 5
    {
43
        return 'zlib.deflate';
44 5
    }
45
}
46