Skip to content

Commit 16b128c

Browse files
committed
Fixed code style
1 parent 705c780 commit 16b128c

11 files changed

+53
-58
lines changed

src/ContentLengthPlugin.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66
use Psr\Http\Message\RequestInterface;
77

88
/**
9-
* Allow to set the correct content length header on the request or to transfer it as a chunk if not possible
9+
* Allow to set the correct content length header on the request or to transfer it as a chunk if not possible.
1010
*
1111
* @author Joel Wurtz <[email protected]>
1212
*/
1313
class ContentLengthPlugin implements Plugin
1414
{
1515
/**
16-
* {@inheritDoc}
16+
* {@inheritdoc}
1717
*/
1818
public function handleRequest(RequestInterface $request, callable $next, callable $first)
1919
{

src/CookiePlugin.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
class CookiePlugin implements Plugin
1616
{
1717
/**
18-
* Cookie storage
18+
* Cookie storage.
1919
*
2020
* @var CookieJar
2121
*/
@@ -54,7 +54,7 @@ public function handleRequest(RequestInterface $request, callable $next, callabl
5454
$request = $request->withAddedHeader('Cookie', sprintf('%s=%s', $cookie->getName(), $cookie->getValue()));
5555
}
5656

57-
return $next($request)->then(function (ResponseInterface $response) use($request) {
57+
return $next($request)->then(function (ResponseInterface $response) use ($request) {
5858
if ($response->hasHeader('Set-Cookie')) {
5959
$setCookies = $response->getHeader('Set-Cookie');
6060

@@ -92,15 +92,15 @@ private function createCookie(RequestInterface $request, $setCookie)
9292
$parts = array_map('trim', explode(';', $setCookie));
9393

9494
if (empty($parts) || !strpos($parts[0], '=')) {
95-
return null;
95+
return;
9696
}
9797

9898
list($name, $cookieValue) = $this->createValueKey(array_shift($parts));
9999

100-
$expires = 0;
101-
$domain = $request->getUri()->getHost();
102-
$path = $request->getUri()->getPath();
103-
$secure = false;
100+
$expires = 0;
101+
$domain = $request->getUri()->getHost();
102+
$path = $request->getUri()->getPath();
103+
$secure = false;
104104
$httpOnly = false;
105105

106106
// Add the cookie pieces into the parsed data array
@@ -113,7 +113,7 @@ private function createCookie(RequestInterface $request, $setCookie)
113113
break;
114114

115115
case 'max-age':
116-
$expires = (new \DateTime())->add(new \DateInterval('PT' . (int)$value . 'S'));
116+
$expires = (new \DateTime())->add(new \DateInterval('PT'.(int) $value.'S'));
117117
break;
118118

119119
case 'domain':
@@ -147,7 +147,7 @@ private function createCookie(RequestInterface $request, $setCookie)
147147
private function createValueKey($part)
148148
{
149149
$parts = explode('=', $part, 2);
150-
$key = trim($parts[0]);
150+
$key = trim($parts[0]);
151151
$value = isset($parts[1]) ? trim($parts[1]) : true;
152152

153153
return [$key, $value];

src/DecoderPlugin.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
namespace Http\Client\Plugin;
44

5-
use Http\Client\Exception;
65
use Http\Encoding\DechunkStream;
76
use Http\Encoding\DecompressStream;
87
use Http\Encoding\GzipDecodeStream;
@@ -12,7 +11,7 @@
1211
use Psr\Http\Message\StreamInterface;
1312

1413
/**
15-
* Allow to decode response body with a chunk, deflate, compress or gzip encoding
14+
* Allow to decode response body with a chunk, deflate, compress or gzip encoding.
1615
*
1716
* @author Joel Wurtz <[email protected]>
1817
*/
@@ -36,7 +35,7 @@ public function __construct($useContentEncoding = true)
3635
}
3736

3837
/**
39-
* {@inheritDoc}
38+
* {@inheritdoc}
4039
*/
4140
public function handleRequest(RequestInterface $request, callable $next, callable $first)
4241
{
@@ -52,7 +51,7 @@ public function handleRequest(RequestInterface $request, callable $next, callabl
5251
}
5352

5453
/**
55-
* Decode a response body given its Transfer-Encoding or Content-Encoding value
54+
* Decode a response body given its Transfer-Encoding or Content-Encoding value.
5655
*
5756
* @param ResponseInterface $response Response to decode
5857
*
@@ -70,7 +69,7 @@ private function decodeResponse(ResponseInterface $response)
7069
}
7170

7271
/**
73-
* Decode a response on a specific header (content encoding or transfer encoding mainly)
72+
* Decode a response on a specific header (content encoding or transfer encoding mainly).
7473
*
7574
* @param string $headerName Name of the header
7675
* @param ResponseInterface $response Response
@@ -80,7 +79,7 @@ private function decodeResponse(ResponseInterface $response)
8079
private function decodeOnEncodingHeader($headerName, ResponseInterface $response)
8180
{
8281
if ($response->hasHeader($headerName)) {
83-
$encodings = $response->getHeader($headerName);
82+
$encodings = $response->getHeader($headerName);
8483
$newEncodings = [];
8584

8685
while ($encoding = array_pop($encodings)) {
@@ -102,7 +101,7 @@ private function decodeOnEncodingHeader($headerName, ResponseInterface $response
102101
}
103102

104103
/**
105-
* Decorate a stream given an encoding
104+
* Decorate a stream given an encoding.
106105
*
107106
* @param string $encoding
108107
* @param StreamInterface $stream

src/EmulateAsyncClient.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
use Http\Client\Tools\HttpClientDecorator;
99

1010
/**
11-
* Emulate an async client
11+
* Emulate an async client.
1212
*/
1313
class EmulateAsyncClient implements HttpClient, HttpAsyncClient
1414
{

src/ErrorPlugin.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ public function handleRequest(RequestInterface $request, callable $next, callabl
3737
{
3838
$promise = $next($request);
3939

40-
return $promise->then(function (ResponseInterface $response) use($request) {
41-
if (preg_match('/'.$this->statusCodeRegex.'/', (string)$response->getStatusCode())) {
40+
return $promise->then(function (ResponseInterface $response) use ($request) {
41+
if (preg_match('/'.$this->statusCodeRegex.'/', (string) $response->getStatusCode())) {
4242
throw new HttpException('The server returned an error', $request, $response);
4343
}
4444

src/LoggerPlugin.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,21 @@
99
use Psr\Log\LoggerInterface;
1010

1111
/**
12-
* Log request, response and exception for a HTTP Client
12+
* Log request, response and exception for a HTTP Client.
1313
*
1414
* @author Joel Wurtz <[email protected]>
1515
*/
1616
class LoggerPlugin implements Plugin
1717
{
1818
/**
19-
* Logger to log request / response / exception for a http call
19+
* Logger to log request / response / exception for a http call.
2020
*
2121
* @var LoggerInterface
2222
*/
2323
private $logger;
2424

2525
/**
26-
* Normalize request and response to string or array
26+
* Normalize request and response to string or array.
2727
*
2828
* @var Normalizer
2929
*/
@@ -34,7 +34,7 @@ class LoggerPlugin implements Plugin
3434
*/
3535
public function __construct(LoggerInterface $logger)
3636
{
37-
$this->logger = $logger;
37+
$this->logger = $logger;
3838
$this->normalizer = new Normalizer();
3939
}
4040

@@ -45,7 +45,7 @@ public function handleRequest(RequestInterface $request, callable $next, callabl
4545
{
4646
$this->logger->info(sprintf('Emit request: "%s"', $this->normalizer->normalizeRequestToString($request)), ['request' => $request]);
4747

48-
return $next($request)->then(function (ResponseInterface $response) use($request) {
48+
return $next($request)->then(function (ResponseInterface $response) use ($request) {
4949
$this->logger->info(
5050
sprintf('Receive response: "%s" for request: "%s"', $this->normalizer->normalizeResponseToString($response), $this->normalizer->normalizeRequestToString($request)),
5151
[
@@ -55,22 +55,22 @@ public function handleRequest(RequestInterface $request, callable $next, callabl
5555
);
5656

5757
return $response;
58-
}, function (Exception $exception) use($request) {
58+
}, function (Exception $exception) use ($request) {
5959
if ($exception instanceof Exception\HttpException) {
6060
$this->logger->error(
6161
sprintf('Error: "%s" with response: "%s" when emitting request: "%s"', $exception->getMessage(), $this->normalizer->normalizeResponseToString($exception->getResponse()), $this->normalizer->normalizeRequestToString($request)),
6262
[
6363
'request' => $request,
6464
'response' => $exception->getResponse(),
65-
'exception' => $exception
65+
'exception' => $exception,
6666
]
6767
);
6868
} else {
6969
$this->logger->error(
7070
sprintf('Error: "%s" when emitting request: "%s"', $exception->getMessage(), $this->normalizer->normalizeRequestToString($request)),
7171
[
7272
'request' => $request,
73-
'exception' => $exception
73+
'exception' => $exception,
7474
]
7575
);
7676
}

src/Normalizer/Normalizer.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
use Psr\Http\Message\ResponseInterface;
77

88
/**
9-
* Normalize a request or a response into a string or an array
9+
* Normalize a request or a response into a string or an array.
1010
*
1111
* @author Joel Wurtz <[email protected]>
1212
*
@@ -15,7 +15,7 @@
1515
class Normalizer
1616
{
1717
/**
18-
* Normalize a request to string
18+
* Normalize a request to string.
1919
*
2020
* @param RequestInterface $request
2121
*
@@ -27,14 +27,14 @@ public function normalizeRequestToString(RequestInterface $request)
2727
}
2828

2929
/**
30-
* Normalize a response to string
30+
* Normalize a response to string.
3131
*
3232
* @param ResponseInterface $response
3333
*
3434
* @return string
3535
*/
3636
public function normalizeResponseToString(ResponseInterface $response)
3737
{
38-
return sprintf("%s %s %s", $response->getStatusCode(), $response->getReasonPhrase(), $response->getProtocolVersion());
38+
return sprintf('%s %s %s', $response->getStatusCode(), $response->getReasonPhrase(), $response->getProtocolVersion());
3939
}
4040
}

src/PluginClient.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
use Http\Client\HttpAsyncClient;
66
use Http\Client\HttpClient;
7-
use Http\Promise\Promise;
87
use Psr\Http\Message\RequestInterface;
98

109
/**
@@ -15,14 +14,14 @@
1514
class PluginClient implements HttpClient, HttpAsyncClient
1615
{
1716
/**
18-
* An HTTP async client
17+
* An HTTP async client.
1918
*
2019
* @var HttpAsyncClient
2120
*/
2221
protected $client;
2322

2423
/**
25-
* The plugin chain
24+
* The plugin chain.
2625
*
2726
* @var Plugin[]
2827
*/
@@ -75,7 +74,7 @@ public function sendAsyncRequest(RequestInterface $request)
7574
private function createPluginChain($pluginList)
7675
{
7776
$client = $this->client;
78-
$lastCallable = function (RequestInterface $request) use($client) {
77+
$lastCallable = function (RequestInterface $request) use ($client) {
7978
return $client->sendAsyncRequest($request);
8079
};
8180

0 commit comments

Comments
 (0)