Completed
Pull Request — master (#5)
by Márk
02:40 queued 37s
created

Chunk   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 2
c 1
b 0
f 1
lcom 1
cbo 0
dl 0
loc 18
ccs 10
cts 10
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A filter() 0 15 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