TwoWayStream   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 1

Importance

Changes 0
Metric Value
wmc 3
lcom 2
cbo 1
dl 0
loc 42
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A read() 0 4 1
A write() 0 6 1
1
<?php
2
3
namespace PHPetroleum\Stream;
4
5
use PHPetroleum\Pipe;
6
use PHPetroleum\Stream\ReadableStream;
7
use PHPetroleum\Stream\WritableStream;
8
9
class TwoWayStream implements ReadableStream, WritableStream
10
{
11
    /**
12
     * @var Pipe $reader
13
     */
14
    private $reader;
15
16
    /**
17
     * @var Pipe $writer
18
     */
19
    private $writer;
20
21
    /**
22
     * @param Pipe $reader The pipe which data is received
23
     * @param Pipe $writer The pipe which data is sent
24
     *
25
     * @return void
0 ignored issues
show
Comprehensibility Best Practice introduced by
Adding a @return annotation to constructors is generally not recommended as a constructor does not have a meaningful return value.

Adding a @return annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.

Please refer to the PHP core documentation on constructors.

Loading history...
26
     */
27
    public function __construct(Pipe $reader, Pipe $writer)
28
    {
29
        $this->reader = $reader;
30
        $this->writer = $writer;
31
    }
32
33
    /**
34
     * {@inheritDoc}
35
     */
36
    public function read()
37
    {
38
        return $this->reader->read();
39
    }
40
41
    /**
42
     * {@inheritDoc}
43
     */
44
    public function write($content)
45
    {
46
        $this->writer->write($content);
47
48
        return $this;
49
    }
50
}
51