ThroughStream::end()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 8
ccs 5
cts 5
cp 1
rs 9.4285
cc 2
eloc 4
nc 2
nop 1
crap 2
c 1
b 0
f 0
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