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 ( 06ff9b...b93e78 )
by Cees-Jan
07:16
created

JsonStream   A

Complexity

Total Complexity 17

Size/Duplication

Total Lines 107
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 21.05%

Importance

Changes 0
Metric Value
wmc 17
lcom 1
cbo 2
dl 0
loc 107
ccs 8
cts 38
cp 0.2105
rs 10
c 0
b 0
f 0

17 Methods

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