Completed
Push — master ( f97e7d...942adb )
by Aurimas
02:25
created

WritableStream::close()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 13
Code Lines 8

Duplication

Lines 13
Ratio 100 %

Code Coverage

Tests 8
CRAP Score 2
Metric Value
dl 13
loc 13
ccs 8
cts 8
cp 1
rs 9.4286
cc 2
eloc 8
nc 2
nop 0
crap 2
1
<?php
2
3
namespace Thruster\Component\Stream;
4
5
use Thruster\Component\EventEmitter\EventEmitterTrait;
6
7
/**
8
 * Class WritableStream
9
 *
10
 * @package Thruster\Component\Stream
11
 * @author  Aurimas Niekis <[email protected]>
12
 */
13
class WritableStream extends BaseStream implements WritableStreamInterface
14
{
15 19
    public function __construct()
16
    {
17 19
        $this->closed = false;
18 19
    }
19
20
    /**
21
     * {@inheritDoc}
22
     */
23 2
    public function write($data)
24
    {
25 2
    }
26
27
    /**
28
     * {@inheritDoc}
29
     */
30 4
    public function end($data = null) : self
31
    {
32 4
        if (null !== $data) {
33 2
            $this->write($data);
34
        }
35
36 4
        $this->close();
37
38 4
        return $this;
39
    }
40
41
    /**
42
     * {@inheritDoc}
43
     */
44 10
    public function isWritable() : bool
45
    {
46 10
        return !$this->closed;
47
    }
48
}
49