Chunk::filter()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 14
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 8
nc 2
nop 4
dl 0
loc 14
ccs 9
cts 9
cp 1
crap 2
rs 10
c 1
b 0
f 0
1
<?php
2
3
namespace Http\Message\Encoding\Filter;
4
5
/**
6
 * Userland implementation of the chunk stream filter.
7
 *
8
 * @author Joel Wurtz <[email protected]>
9
 */
10
class Chunk extends \php_user_filter
11
{
12
    /**
13
     * {@inheritdoc}
14
     */
15 2
    public function filter($in, $out, &$consumed, $closing)
16
    {
17 2
        while ($bucket = stream_bucket_make_writeable($in)) {
18 2
            $lenbucket = stream_bucket_new($this->stream, dechex($bucket->datalen)."\r\n");
0 ignored issues
show
Bug Best Practice introduced by
The property stream does not exist on Http\Message\Encoding\Filter\Chunk. Did you maybe forget to declare it?
Loading history...
19 2
            stream_bucket_append($out, $lenbucket);
20
21 2
            $consumed += $bucket->datalen;
22 2
            stream_bucket_append($out, $bucket);
23
24 2
            $lenbucket = stream_bucket_new($this->stream, "\r\n");
25 2
            stream_bucket_append($out, $lenbucket);
26
        }
27
28 2
        return PSFS_PASS_ON;
29
    }
30
}
31