ThroughStream::write()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 1
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
3
namespace Thruster\Component\Stream;
4
5
/**
6
 * Class ThroughStream
7
 *
8
 * @package Thruster\Component\Stream
9
 * @author  Aurimas Niekis <[email protected]>
10
 */
11
class ThroughStream extends CompositeStream
12
{
13 11
    public function __construct()
14
    {
15 11
        $readable = new ReadableStream();
16 11
        $writable = new WritableStream();
17
18 11
        parent::__construct($readable, $writable);
19 11
    }
20
21 4
    public function filter($data)
22
    {
23 4
        return $data;
24
    }
25
26
    /**
27
     * {@inheritDoc}
28
     */
29 3
    public function write($data)
30
    {
31 3
        $this->readable->emit('data', [$this->filter($data), $this]);
32 3
    }
33
34
    /**
35
     * {@inheritDoc}
36
     */
37 2
    public function end($data = null)
38
    {
39 2
        if (null !== $data) {
40 1
            $this->readable->emit('data', [$this->filter($data), $this]);
41
        }
42
43 2
        $this->writable->end($data);
44 2
    }
45
}
46