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
Pull Request — master (#10)
by Lukáš
01:47
created

Response::hasHeader()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace Lookyman\Nette\OAuth2\Server\Psr7;
6
7
use Nette\Http\IRequest;
8
use Nette\Http\IResponse;
9
use Nette\NotImplementedException;
10
use Psr\Http\Message\StreamInterface;
11
use Zend\Diactoros\Stream;
12
13
final class Response implements ApplicationPsr7ResponseInterface
14
{
15
16
	/**
17
	 * @var int
18
	 */
19
	private $code = IResponse::S200_OK;
20
21
	/**
22
	 * @var array
23
	 */
24
	private $headers = [];
25
26
	/**
27
	 * @var StreamInterface
28
	 */
29
	private $stream;
30
31
	public function send(IRequest $httpRequest, IResponse $httpResponse)
32
	{
33
		$httpResponse->setCode($this->code);
34
		foreach ($this->headers as $name => $value) {
35
			$httpResponse->setHeader($name, $value);
36
		}
37
		echo (string) $this->getBody();
38
	}
39
40
	/**
41
	 * @param string $name
42
	 * @param string|string[] $value
43
	 * @phpcsSuppress SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingParameterTypeHint
44
	 */
45
	public function withHeader($name, $value): Response
46
	{
47
		$response = clone $this;
48
		$response->headers[$name] = $value;
49
		return $response;
50
	}
51
52
	public function getBody(): StreamInterface
53
	{
54
		if (!$this->stream) {
55
			$this->stream = new Stream('php://temp', 'r+');
0 ignored issues
show
Documentation Bug introduced by
It seems like new \Zend\Diactoros\Stream('php://temp', 'r+') of type object<Zend\Diactoros\Stream> is incompatible with the declared type object<Psr\Http\Message\StreamInterface> of property $stream.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
56
		}
57
		return $this->stream;
58
	}
59
60
	/**
61
	 * @param int $code
62
	 * @param string $reasonPhrase
63
	 * @phpcsSuppress SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingParameterTypeHint
64
	 */
65
	public function withStatus($code, $reasonPhrase = ''): Response
66
	{
67
		$response = clone $this;
68
		$response->code = $code;
69
		return $response;
70
	}
71
72
	public function withBody(StreamInterface $body): Response
73
	{
74
		$response = clone $this;
75
		$response->stream = $body;
76
		return $response;
77
	}
78
79
	public function getProtocolVersion()
80
	{
81
		throw new NotImplementedException();
82
	}
83
84
	/**
85
	 * @phpcsSuppress SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingParameterTypeHint
86
	 */
87
	public function withProtocolVersion($version)
88
	{
89
		throw new NotImplementedException();
90
	}
91
92
	public function getHeaders()
93
	{
94
		throw new NotImplementedException();
95
	}
96
97
	/**
98
	 * @phpcsSuppress SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingParameterTypeHint
99
	 */
100
	public function hasHeader($name)
101
	{
102
		throw new NotImplementedException();
103
	}
104
105
	/**
106
	 * @phpcsSuppress SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingParameterTypeHint
107
	 */
108
	public function getHeader($name)
109
	{
110
		throw new NotImplementedException();
111
	}
112
113
	/**
114
	 * @phpcsSuppress SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingParameterTypeHint
115
	 */
116
	public function getHeaderLine($name)
117
	{
118
		throw new NotImplementedException();
119
	}
120
121
	/**
122
	 * @phpcsSuppress SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingParameterTypeHint
123
	 */
124
	public function withAddedHeader($name, $value)
125
	{
126
		throw new NotImplementedException();
127
	}
128
129
	/**
130
	 * @phpcsSuppress SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingParameterTypeHint
131
	 */
132
	public function withoutHeader($name)
133
	{
134
		throw new NotImplementedException();
135
	}
136
137
	public function getStatusCode()
138
	{
139
		throw new NotImplementedException();
140
	}
141
142
	public function getReasonPhrase()
143
	{
144
		throw new NotImplementedException();
145
	}
146
147
}
148