Completed
Pull Request — master (#41)
by Vladimir
02:32
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)
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $in. Configured minimum length is 3.

Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.

Loading history...
20
    {
21
        while ($bucket = stream_bucket_make_writeable($in)) {
22
            self::$output .= $bucket->data;
23
            $consumed += $bucket->datalen;
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 5 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
24
        }
25
26
        return PSFS_PASS_ON;
27
    }
28
}
29