GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 83923d...f0a1ce )
by Cees-Jan
03:49
created

WritableStreamBase64Encode   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 77.27%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 2
dl 0
loc 58
ccs 17
cts 22
cp 0.7727
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A isWritable() 0 4 1
A write() 0 6 1
A end() 0 8 1
A close() 0 4 1
A processBuffer() 0 8 1
1
<?php declare(strict_types=1);
2
3
namespace WyriHaximus\React\Stream\Base64;
4
5
use Evenement\EventEmitterTrait;
6
use React\Stream\WritableStreamInterface;
7
8
final class WritableStreamBase64Encode implements WritableStreamInterface
9
{
10
    use EventEmitterTrait;
11
12
    /**
13
     * @var WritableStreamInterface
14
     */
15
    private $stream;
16
17
    /**
18
     * @var string
19
     */
20
    private $buffer = '';
21
22
    /**
23
     * WritableStreamHash constructor.
24
     * @param WritableStreamInterface $stream
25
     */
26 12
    public function __construct(WritableStreamInterface $stream)
27
    {
28 12
        $this->stream = $stream;
29 12
    }
30
31
    public function isWritable()
32
    {
33
        return $this->stream->isWritable();
34
    }
35
36 11
    public function write($data)
37
    {
38 11
        $this->buffer .= $data;
39
40 11
        return $this->stream->write($this->processBuffer());
41
    }
42
43 12
    public function end($data = null)
44
    {
45 12
        $this->buffer .= $data;
46 12
        $this->stream->end(
47 12
            $this->processBuffer() . base64_encode($this->buffer)
48
        );
49 12
        $this->buffer = '';
50 12
    }
51
52
    public function close()
53
    {
54
        $this->stream->close();
55
    }
56
57 12
    private function processBuffer(): string
58
    {
59 12
        $length = strlen($this->buffer);
60 12
        $buffer = base64_encode(substr($this->buffer, 0, $length - $length % 3));
61 12
        $this->buffer = substr($this->buffer, $length - $length % 3);
62
63 12
        return $buffer;
64
    }
65
}
66