Completed
Branch master (91c650)
by Ryuichi
05:32 queued 02:45
created

ConsoleOutputStream::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
namespace WebStream\IO;
3
4
/**
5
 * ConsoleOutputStream
6
 * @author Ryuichi TANAKA.
7
 * @since 2016/02/27
8
 * @version 0.7
9
 */
10
class ConsoleOutputStream extends OutputStream
11
{
12
    /**
13
     * constructor
14
     */
15
    public function __construct()
16
    {
17
        parent::__construct("");
18
    }
19
20
    /**
21
     * {@inheritdoc}
22
     */
23
    public function write($buf, int $off = null, int $len = null)
24
    {
25
        $data = null;
0 ignored issues
show
Unused Code introduced by
$data is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
26
        if ($off === null && $len === null) {
27
            $data = $buf;
28
        } elseif ($off !== null && $len === null) {
29
            $data = substr($buf, $off);
30
        } elseif ($off === null && $len !== null) {
31
            $data = substr($buf, 0, $len);
32
        } else {
33
            $data = substr($buf, $off, $len);
34
        }
35
36
        $this->stream .= $data;
37
    }
38
39
    /**
40
     * {@inheritdoc}
41
     */
42
    public function close()
43
    {
44
        $this->stream = null;
45
    }
46
47
    /**
48
     * {@inheritdoc}
49
     */
50
    public function flush()
51
    {
52
        echo $this->stream;
53
    }
54
}
55