TwoWayStream::write()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 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