Completed
Pull Request — master (#41)
by Vladimir
02:35
created

StreamInterceptor   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 15
rs 10
c 0
b 0
f 0
wmc 2
lcom 1
cbo 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A filter() 0 10 2
1
<?php
2
3
namespace allejo\stakx\Test;
4
5
/**
6
 * Class StreamIntercept
7
 *
8
 * @link http://stackoverflow.com/a/39785995
9
 */
10
class StreamInterceptor extends \php_user_filter
11
{
12
    public static $output = '';
13
14
    public function filter($in, $out, &$consumed, $closing)
15
    {
16
        while ($bucket = stream_bucket_make_writeable($in))
17
        {
18
            self::$output .= $bucket->data;
19
            $consumed += $bucket->datalen;
20
        }
21
22
        return PSFS_PASS_ON;
23
    }
24
}