ThroughStream   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
lcom 1
cbo 5
dl 0
loc 35
ccs 15
cts 15
cp 1
rs 10
c 1
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A filter() 0 4 1
A write() 0 4 1
A __construct() 0 7 1
A end() 0 8 2
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