Skip to content

Commit 4845a86

Browse files
authored
Merge pull request #87 from php-http/analysis-8mdGkb
Apply fixes from StyleCI
2 parents 4b777b6 + f13200b commit 4845a86

File tree

5 files changed

+12
-11
lines changed

5 files changed

+12
-11
lines changed

src/Builder/ResponseBuilder.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public function setHeadersFromString($headers)
104104
public function setStatus($statusLine)
105105
{
106106
$parts = explode(' ', $statusLine, 3);
107-
if (count($parts) < 2 || strpos(strtolower($parts[0]), 'http/') !== 0) {
107+
if (count($parts) < 2 || 0 !== strpos(strtolower($parts[0]), 'http/')) {
108108
throw new \InvalidArgumentException(
109109
sprintf('"%s" is not a valid HTTP status line', $statusLine)
110110
);
@@ -130,7 +130,7 @@ public function setStatus($statusLine)
130130
public function addHeader($headerLine)
131131
{
132132
$parts = explode(':', $headerLine, 2);
133-
if (count($parts) !== 2) {
133+
if (2 !== count($parts)) {
134134
throw new \InvalidArgumentException(
135135
sprintf('"%s" is not a valid HTTP header line', $headerLine)
136136
);

src/Cookie.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ public function withDomain($domain)
295295
public function matchDomain($domain)
296296
{
297297
// Domain is not set or exact match
298-
if (!$this->hasDomain() || strcasecmp($domain, $this->domain) === 0) {
298+
if (!$this->hasDomain() || 0 === strcasecmp($domain, $this->domain)) {
299299
return true;
300300
}
301301

@@ -343,7 +343,7 @@ public function withPath($path)
343343
*/
344344
public function matchPath($path)
345345
{
346-
return $this->path === $path || (strpos($path, rtrim($this->path, '/').'/') === 0);
346+
return $this->path === $path || (0 === strpos($path, rtrim($this->path, '/').'/'));
347347
}
348348

349349
/**
@@ -405,7 +405,7 @@ public function withHttpOnly($httpOnly)
405405
*
406406
* @return bool
407407
*/
408-
public function match(Cookie $cookie)
408+
public function match(self $cookie)
409409
{
410410
return $this->name === $cookie->name && $this->domain === $cookie->domain and $this->path === $cookie->path;
411411
}
@@ -517,7 +517,7 @@ private function normalizePath($path)
517517
{
518518
$path = rtrim($path, '/');
519519

520-
if (empty($path) or substr($path, 0, 1) !== '/') {
520+
if (empty($path) or '/' !== substr($path, 0, 1)) {
521521
$path = '/';
522522
}
523523

src/Encoding/FilteredStream.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public function read($length)
9898
*/
9999
public function eof()
100100
{
101-
return $this->stream->eof() && $this->buffer === '';
101+
return $this->stream->eof() && '' === $this->buffer;
102102
}
103103

104104
/**
@@ -128,7 +128,7 @@ public function getContents()
128128
while (!$this->eof()) {
129129
$buf = $this->read(self::BUFFER_SIZE);
130130
// Using a loose equality here to match on '' and false.
131-
if ($buf == null) {
131+
if (null == $buf) {
132132
break;
133133
}
134134

src/Formatter/CurlCommandFormatter.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ class CurlCommandFormatter implements Formatter
1919
public function formatRequest(RequestInterface $request)
2020
{
2121
$command = sprintf('curl %s', escapeshellarg((string) $request->getUri()->withFragment('')));
22-
if ($request->getProtocolVersion() === '1.0') {
22+
if ('1.0' === $request->getProtocolVersion()) {
2323
$command .= ' --http1.0';
24-
} elseif ($request->getProtocolVersion() === '2.0') {
24+
} elseif ('2.0' === $request->getProtocolVersion()) {
2525
$command .= ' --http2';
2626
}
2727

@@ -69,6 +69,7 @@ private function getHeadersAsCommandOptions(RequestInterface $request)
6969

7070
if ('user-agent' === strtolower($name)) {
7171
$command .= sprintf(' -A %s', escapeshellarg($values[0]));
72+
7273
continue;
7374
}
7475

src/Formatter/FullHttpMessageFormatter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public function formatResponse(ResponseInterface $response)
7878
private function addBody(MessageInterface $request, $message)
7979
{
8080
$stream = $request->getBody();
81-
if (!$stream->isSeekable() || $this->maxBodyLength === 0) {
81+
if (!$stream->isSeekable() || 0 === $this->maxBodyLength) {
8282
// Do not read the stream
8383
$message .= "\n";
8484
} else {

0 commit comments

Comments
 (0)