Completed
Pull Request — master (#5)
by Márk
03:51
created

Chunk::filter()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 15
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 15
ccs 10
cts 10
cp 1
rs 9.4286
cc 2
eloc 9
nc 2
nop 4
crap 2
1
<?php
2
3
namespace Http\Message\Encoding\Filter;
4
5
class Chunk extends \php_user_filter
6
{
7 8
    public function filter($in, $out, &$consumed, $closing)
8
    {
9 8
        while ($bucket = stream_bucket_make_writeable($in)) {
10 2
            $lenbucket = stream_bucket_new($this->stream, dechex($bucket->datalen)."\r\n");
0 ignored issues
show
Bug introduced by
The property stream does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
11 2
            stream_bucket_append($out, $lenbucket);
12
13 2
            $consumed += $bucket->datalen;
14 2
            stream_bucket_append($out, $bucket);
15
16 2
            $lenbucket = stream_bucket_new($this->stream, "\r\n");
17 2
            stream_bucket_append($out, $lenbucket);
18 2
        }
19
20 8
        return PSFS_PASS_ON;
21
    }
22
}
23