Completed
Pull Request — master (#41)
by Vladimir
04:25
created

StreamInterceptor   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

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

1 Method

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