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::write()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

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