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 ( ad528d...98e8f7 )
by Cees-Jan
10s
created

JsonStream::__toString()   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 ApiClients\Middleware\Json;
4
5
use Psr\Http\Message\StreamInterface;
6
use RingCentral\Psr7\BufferStream;
7
8
class JsonStream implements StreamInterface
9
{
10
    /**
11
     * @var array
12
     */
13
    private $json = [];
14
15
    /**
16
     * @var StreamInterface
17
     */
18
    private $bufferStream;
19
20 3
    public function __construct(array $json)
21
    {
22 3
        $this->json = $json;
23 3
        $jsonString = json_encode($json);
24 3
        $this->bufferStream = new BufferStream(strlen($jsonString));
25 3
        $this->bufferStream->write($jsonString);
26 3
    }
27
28
    /**
29
     * @return array
30
     */
31 3
    public function getJson()
32
    {
33 3
        return $this->json;
34
    }
35
36
    public function __toString()
37
    {
38
        return $this->getContents();
39
    }
40
41 1
    public function getContents()
42
    {
43 1
        return $this->bufferStream->getContents();
44
    }
45
46
    public function close()
47
    {
48
    }
49
50
    public function detach()
51
    {
52
    }
53
54 1
    public function getSize()
55
    {
56 1
        return $this->bufferStream->getSize();
57
    }
58
59
    public function isReadable()
60
    {
61
        return $this->bufferStream->isReadable();
62
    }
63
64
    public function isWritable()
65
    {
66
        return $this->bufferStream->isWritable();
67
    }
68
69
    public function isSeekable()
70
    {
71
        return $this->bufferStream->isSeekable();
72
    }
73
74
    public function rewind()
75
    {
76
        return $this->bufferStream->rewind();
77
    }
78
79
    public function seek($offset, $whence = SEEK_SET)
80
    {
81
        return $this->bufferStream->seek($offset, $whence);
82
    }
83
84
    public function eof()
85
    {
86
        return $this->bufferStream->eof();
87
    }
88
89
    public function tell()
90
    {
91
        return $this->bufferStream->tell();
92
    }
93
94
    /**
95
     * Reads data from the buffer.
96
     */
97
    public function read($length)
98
    {
99
        return $this->bufferStream->read($length);
100
    }
101
102
    /**
103
     * Writes data to the buffer.
104
     */
105
    public function write($string)
106
    {
107
        return $this->bufferStream->write($string);
108
    }
109
110
    public function getMetadata($key = null)
111
    {
112
        return $this->bufferStream->getMetadata($key);
113
    }
114
}
115