Code style changes

This commit is contained in:
Ismo Vuorinen
2023-03-09 14:40:55 +02:00
parent 12350f6c0a
commit 7e67ef3c95
2 changed files with 21 additions and 20 deletions

View File

@@ -194,7 +194,7 @@ class Curly
*/
public function __destruct()
{
if ($this->ch !== null) {
if ($this->ch !== false) {
$this->closeTransport();
}
}
@@ -304,6 +304,7 @@ class Curly
return $this;
}
/**
* @return array|string[]
*/
@@ -354,7 +355,7 @@ class Curly
{
$this->ch = curl_init();
if (!$this->ch) {
if ($this->ch === false) {
throw new Exceptions\HTTPException("Could not init data channel");
}
@@ -408,7 +409,7 @@ class Curly
return false;
}
return match ($this->httpVersion) {
match ($this->httpVersion) {
'1.0' => curl_setopt(
$this->ch,
CURLOPT_HTTP_VERSION,
@@ -425,6 +426,8 @@ class Curly
CURL_HTTP_VERSION_NONE
),
};
return true;
}
private function initCurlAuthenticationMethod(): void
@@ -510,6 +513,7 @@ class Curly
}
switch ($this->method) {
default:
case 'GET':
$payload = empty($data)
? $this->address
@@ -520,8 +524,7 @@ class Curly
CURLOPT_URL,
$payload
);
return;
break;
case 'PUT':
curl_setopt(
@@ -549,7 +552,7 @@ class Curly
$this->address
);
return;
break;
case 'POST':
curl_setopt(
@@ -576,7 +579,7 @@ class Curly
$this->address
);
return;
break;
case 'DELETE':
curl_setopt(
@@ -604,7 +607,7 @@ class Curly
$this->address
);
return;
break;
}
}
@@ -803,10 +806,10 @@ class Curly
* Send data via STREAM
*
* @uses \League\Uri\Uri
* @uses \League\Uri\Uri
* @return string
*
* @throws Exceptions\HTTPException
* @uses \League\Uri\Uri
*/
private function sendUsingStream(): string
{
@@ -970,9 +973,11 @@ class Curly
if (!in_array($method, $this->supportedHttpMethods, true)) {
throw new Exceptions\HTTPException(
"Unsupported HTTP method: " . $method
. '. Should be one of: '
. implode(', ', $this->supportedHttpMethods)
sprintf(
"Unsupported HTTP method: %s. Should be one of: %s",
$method,
implode(', ', $this->supportedHttpMethods)
)
);
}

View File

@@ -12,8 +12,6 @@ class CurlyBasicsTest extends TestCase
* This is just a simple check to make sure your library has no
* syntax error. This helps you troubleshoot any typo before you
* even use this library in a real project.
*
* @throws \ivuorinen\Curly\Exceptions\HTTPException
*/
public function testIsThereAnySyntaxError(): void
{
@@ -28,8 +26,6 @@ class CurlyBasicsTest extends TestCase
* This is just a simple check to make sure your library has no
* syntax error. This helps you troubleshoot any typo before you
* even use this library in a real project.
*
* @throws \ivuorinen\Curly\Exceptions\HTTPException
*/
public function testParseData(): void
{