diff --git a/composer.json b/composer.json index 42e0070..cc70203 100644 --- a/composer.json +++ b/composer.json @@ -4,12 +4,12 @@ "type": "library", "license": "MIT", "require": { - "php": ">=8.0" + "php": ">=8.1" }, "require-dev": { + "phpstan/phpstan": "^1.10", "phpunit/phpunit": "^9.5", - "laravel/pint": "^1.5.0", - "phpstan/phpstan": "^1.10" + "laravel/pint": "^1.5.0" }, "scripts": { "lint": "./vendor/bin/pint --test --config pint.json", diff --git a/src/Client.php b/src/Client.php index 37659eb..4b6772b 100644 --- a/src/Client.php +++ b/src/Client.php @@ -48,6 +48,29 @@ public function addHeader(string $key, string $value): self return $this; } + /** + * Remove a specific header. + * + * @param string $key + * @return self + */ + public function removeHeader(string $key): self + { + unset($this->headers[strtolower($key)]); + return $this; + } + + /** + * Clear all headers. + * + * @return self + */ + public function clearHeaders(): self + { + $this->headers = []; + return $this; + } + /** * Set the request timeout. * diff --git a/src/Exception.php b/src/Exception.php index 29a3f1b..453bc9c 100644 --- a/src/Exception.php +++ b/src/Exception.php @@ -12,7 +12,7 @@ public function __construct($message) { parent::__construct($message); // Call the parent constructor } - public function __toString() + public function __toString(): string { return __CLASS__ . " {$this->message}\n"; // Return the class name, code and message } diff --git a/src/Response.php b/src/Response.php index 9d69ddd..54a79bb 100644 --- a/src/Response.php +++ b/src/Response.php @@ -46,7 +46,7 @@ public function __construct( $this->headers = $headers; $this->statusCode = $statusCode; } - # Getters + /** * This method is used to get the response body as string * @return mixed @@ -55,6 +55,7 @@ public function getBody(): mixed { return $this->body; } + /** * This method is used to get the response headers * @return array @@ -63,6 +64,7 @@ public function getHeaders(): array { return $this->headers; } + /** * This method is used to get the response status code * @return int @@ -71,19 +73,19 @@ public function getStatusCode(): int { return $this->statusCode; } - // Methods /** - * This method is used to convert the response body to text - * @return string - */ + * This method is used to convert the response body to text + * @return string + */ public function text(): string { return \strval($this->body); } + /** - * This method is used to convert the response body to JSON - * @return mixed + * This method is used to convert the response body to JSON + * @return mixed */ public function json(): mixed { @@ -94,10 +96,10 @@ public function json(): mixed return $data; } - /* - * This method is used to convert the response body to blob - * @return string - */ + /** + * This method is used to convert the response body to blob + * @return string + */ public function blob(): string { $bin = "";