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 ( 80e1a2...dbc788 )
by Cees-Jan
01:26
created

WritableStreamHash::isWritable()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 2
1
<?php declare(strict_types=1);
2
3
namespace WyriHaximus\React\Stream\Hash;
4
5
use Evenement\EventEmitter;
6
use React\Stream\WritableStreamInterface;
7
8
final class WritableStreamHash extends EventEmitter implements WritableStreamInterface
9
{
10
    /**
11
     * @var WritableStreamInterface
12
     */
13
    private $stream;
14
15
    /**
16
     * @var resource
17
     */
18
    private $context;
19
20
    /**
21
     * WritableStreamHash constructor.
22
     * @param WritableStreamInterface $stream
23
     */
24 184
    public function __construct(WritableStreamInterface $stream, string $algo, int $options = 0, string $key = '')
25
    {
26 184
        $this->stream = $stream;
27 184
        $this->context = hash_init($algo, $options, $key);
28 184
        $this->stream->once('close', function () use ($algo) {
29 184
            $this->emit('hash', [
30 184
                hash_final($this->context),
31 184
                $algo,
32
            ]);
33 184
        });
34 184
    }
35
36
    public function isWritable()
37
    {
38
        return $this->stream->isWritable();
39
    }
40
41 184
    public function write($data)
42
    {
43 184
        hash_update($this->context, $data);
44
45 184
        return $this->stream->write($data);
46
    }
47
48 184
    public function end($data = null)
49
    {
50 184
        if ($data !== null) {
51
            hash_update($this->context, $data);
52
        }
53 184
        $this->stream->end($data);
54 184
    }
55
56
    public function close()
57
    {
58
        $this->stream->close();
59
    }
60
}
61