From 661c1dd40c994689245cc623457bcb75cf80f4ac Mon Sep 17 00:00:00 2001 From: DevHero Date: Wed, 3 Jun 2026 21:53:32 +0700 Subject: [PATCH 1/8] Implement getHeaders method in Curl class Add method to retrieve custom headers in Curl class. --- src/Curl/Curl.php | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/Curl/Curl.php b/src/Curl/Curl.php index 5794b9f..355235d 100644 --- a/src/Curl/Curl.php +++ b/src/Curl/Curl.php @@ -480,6 +480,32 @@ public function setHeader($key, $value) $this->setOpt(CURLOPT_HTTPHEADER, array_values($this->_headers)); return $this; } + + /** + * Provide header information. + * + * Provide your customized optional headers. + * + * ```php + * $curl = new Curl(); + * $curl->getHeaders(); + * ``` + * + * @param string $key The header key + * @param string $value The value for the given header key + * @return self + */ + public function getHeaders + { + $headers = []; + + foreach ($this->_headers as $value) + { + list($name, $value) = explode(": ", $value, 2); + $headers[trim($name)] = trim($value); + } + return $headers; + } /** * Provide a User Agent. From 73b7409865a141fe5d01d70db1f17ea46fbfe6c1 Mon Sep 17 00:00:00 2001 From: DevHero Date: Wed, 3 Jun 2026 21:58:01 +0700 Subject: [PATCH 2/8] Fix missing parentheses in getHeaders method --- src/Curl/Curl.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Curl/Curl.php b/src/Curl/Curl.php index 355235d..660d003 100644 --- a/src/Curl/Curl.php +++ b/src/Curl/Curl.php @@ -495,10 +495,9 @@ public function setHeader($key, $value) * @param string $value The value for the given header key * @return self */ - public function getHeaders + public function getHeaders() { $headers = []; - foreach ($this->_headers as $value) { list($name, $value) = explode(": ", $value, 2); From 6dd93b4e4fbb2b58b5d013b32e6d477b85eb1696 Mon Sep 17 00:00:00 2001 From: DevHero Date: Wed, 3 Jun 2026 22:08:59 +0700 Subject: [PATCH 3/8] Change return type of getHeaders to array Updated the return type of getHeaders method to array. --- src/Curl/Curl.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Curl/Curl.php b/src/Curl/Curl.php index 660d003..6c916f2 100644 --- a/src/Curl/Curl.php +++ b/src/Curl/Curl.php @@ -491,9 +491,7 @@ public function setHeader($key, $value) * $curl->getHeaders(); * ``` * - * @param string $key The header key - * @param string $value The value for the given header key - * @return self + * @return array */ public function getHeaders() { From 63d610500d8418e155eed61233c265a8f413c669 Mon Sep 17 00:00:00 2001 From: DevHero Date: Wed, 3 Jun 2026 22:34:21 +0700 Subject: [PATCH 4/8] Change PHP requirement from ^8.0 to ^7.0 --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index dc4bde8..4734f66 100644 --- a/composer.json +++ b/composer.json @@ -24,7 +24,7 @@ } ], "require": { - "php": "^8.0", + "php": "^7.0", "ext-curl": "*", "ext-json": "*" }, @@ -39,4 +39,4 @@ "scripts": { "phpstan": "./phpstan.phar -v" } -} \ No newline at end of file +} From aaa0f1e64dbefd972662ebba60e7b0d2acd057af Mon Sep 17 00:00:00 2001 From: DevHero Date: Wed, 3 Jun 2026 22:40:28 +0700 Subject: [PATCH 5/8] Upgrade PHP requirement from ^7.0 to ^8.0 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 4734f66..b0070fa 100644 --- a/composer.json +++ b/composer.json @@ -24,7 +24,7 @@ } ], "require": { - "php": "^7.0", + "php": "^8.0", "ext-curl": "*", "ext-json": "*" }, From 38e5400cd84460095268ec6511e8655aa0a28e99 Mon Sep 17 00:00:00 2001 From: DevHero Date: Wed, 3 Jun 2026 22:41:25 +0700 Subject: [PATCH 6/8] Update composer.json From 510d49823ae2991831fdd4d227881a5c02860e28 Mon Sep 17 00:00:00 2001 From: DevHero Date: Wed, 3 Jun 2026 22:41:27 +0700 Subject: [PATCH 7/8] Fix JSON syntax error in composer.json From 8684e225fe3e561d1cdcd8943c4c1c83478e3d2f Mon Sep 17 00:00:00 2001 From: DevHero Date: Wed, 3 Jun 2026 23:37:05 +0700 Subject: [PATCH 8/8] Refactor getHeaders to improve variable naming --- src/Curl/Curl.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Curl/Curl.php b/src/Curl/Curl.php index 6c916f2..3127181 100644 --- a/src/Curl/Curl.php +++ b/src/Curl/Curl.php @@ -496,10 +496,10 @@ public function setHeader($key, $value) public function getHeaders() { $headers = []; - foreach ($this->_headers as $value) + foreach ($this->_headers as $header) { - list($name, $value) = explode(": ", $value, 2); - $headers[trim($name)] = trim($value); + $values = explode(": ", $header, 2); + $headers[trim($values[0])] = trim($values[1]); } return $headers; }