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

BaseStream   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%
Metric Value
wmc 2
lcom 1
cbo 2
dl 0
loc 27
ccs 8
cts 8
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A close() 0 13 2
1
<?php
2
3
namespace Thruster\Component\Stream;
4
5
use Thruster\Component\EventEmitter\EventEmitterTrait;
6
7
/**
8
 * Class BaseStream
9
 *
10
 * @package Thruster\Component\Stream
11
 * @author  Aurimas Niekis <[email protected]>
12
 */
13
class BaseStream implements StreamInterface
14
{
15
    use EventEmitterTrait;
16
    use UtilsTrait;
17
18
    /**
19
     * @var bool
20
     */
21
    protected $closed;
22
23
    /**
24
     * {@inheritDoc}
25
     */
26 10
    public function close() : self
27
    {
28 10
        if ($this->closed) {
29 6
            return $this;
30
        }
31
32 10
        $this->closed = true;
33 10
        $this->emit('end', [$this]);
34 10
        $this->emit('close', [$this]);
35 10
        $this->removeListeners();
36
37 10
        return $this;
38
    }
39
}
40