-
Notifications
You must be signed in to change notification settings - Fork 22
Issue/563 http client request factory #564
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
armanist
merged 5 commits into
quantum-php:master
from
armanist:issue/563-http-client-request-factory
Jul 18, 2026
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
0fc8872
[#563] Refactor HttpClient request factory
armanist 578ae71
[#563] Remove unused HttpClient type enum
armanist e08f67a
[#563] Add HttpClient request helpers
armanist de9fe08
[#563] Update HttpClient factory helper tests
armanist 34b554c
[#563] Align HttpClient adapter start contract
armanist File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| <?php | ||
|
|
||
| /** | ||
| * Quantum PHP Framework | ||
| * An open-source software development framework for PHP | ||
| * @link https://quantumphp.io | ||
| */ | ||
|
|
||
| use Quantum\HttpClient\Factories\HttpClientFactory; | ||
| use Quantum\HttpClient\HttpClient; | ||
|
|
||
| /** | ||
| * Creates single HTTP request client | ||
| */ | ||
| function httpRequest(string $url): HttpClient | ||
| { | ||
| return HttpClientFactory::createRequest($url); | ||
| } | ||
|
|
||
| /** | ||
| * Creates multi HTTP request client | ||
| */ | ||
| function httpMultiRequest(): HttpClient | ||
| { | ||
| return HttpClientFactory::createMultiRequest(); | ||
| } | ||
|
|
||
| /** | ||
| * Creates async multi HTTP request client | ||
| */ | ||
| function httpAsyncMultiRequest(callable $success, callable $error): HttpClient | ||
| { | ||
| return HttpClientFactory::createAsyncMultiRequest($success, $error); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
tests/Unit/HttpClient/Helpers/HttpClientHelperFunctionsTest.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| <?php | ||
|
|
||
| namespace Quantum\Tests\Unit\HttpClient\Helpers; | ||
|
|
||
| use Quantum\HttpClient\Adapters\MultiCurlAdapter; | ||
| use Quantum\HttpClient\Adapters\CurlAdapter; | ||
| use Quantum\Tests\Unit\AppTestCase; | ||
| use Quantum\HttpClient\HttpClient; | ||
|
|
||
| class HttpClientHelperFunctionsTest extends AppTestCase | ||
| { | ||
| public function testHttpRequestHelperCreatesSingleRequest(): void | ||
| { | ||
| $httpClient1 = httpRequest('https://example.com'); | ||
| $httpClient2 = httpRequest('https://example.org'); | ||
|
|
||
| $this->assertInstanceOf(HttpClient::class, $httpClient1); | ||
| $this->assertInstanceOf(CurlAdapter::class, $httpClient1->getAdapter()); | ||
| $this->assertNotSame($httpClient1, $httpClient2); | ||
| } | ||
|
|
||
| public function testHttpMultiRequestHelperCreatesMultiRequest(): void | ||
| { | ||
| $httpClient1 = httpMultiRequest(); | ||
| $httpClient2 = httpMultiRequest(); | ||
|
|
||
| $this->assertInstanceOf(HttpClient::class, $httpClient1); | ||
| $this->assertTrue($httpClient1->isMultiRequest()); | ||
| $this->assertInstanceOf(MultiCurlAdapter::class, $httpClient1->getAdapter()); | ||
| $this->assertNotSame($httpClient1, $httpClient2); | ||
| } | ||
|
|
||
| public function testHttpAsyncMultiRequestHelperCreatesAsyncMultiRequest(): void | ||
| { | ||
| $success = static function (): void { | ||
| }; | ||
|
|
||
| $error = static function (): void { | ||
| }; | ||
|
|
||
| $httpClient1 = httpAsyncMultiRequest($success, $error); | ||
| $httpClient2 = httpAsyncMultiRequest($success, $error); | ||
|
|
||
| $this->assertInstanceOf(HttpClient::class, $httpClient1); | ||
| $this->assertTrue($httpClient1->isMultiRequest()); | ||
| $this->assertInstanceOf(MultiCurlAdapter::class, $httpClient1->getAdapter()); | ||
| $this->assertNotSame($httpClient1, $httpClient2); | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.