Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@
/.phpunit.result.cache
/phpunit.xml

/composer.lock

/vendor/
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.0.2] - 2025-04-22

### Added
- PathBuilder classes

## [0.0.1] - 2025-04-22

### Added
- StaticHttpClient, HostnameAwareResolver classes

[Unreleased]: https://github.com/FreeElephants/static-http-client/compare/0.0.1...HEAD
[Unreleased]: https://github.com/FreeElephants/static-http-client/compare/0.0.2...HEAD
[0.0.2]: https://github.com/FreeElephants/static-http-client/releases/tag/0.0.2
[0.0.1]: https://github.com/FreeElephants/static-http-client/releases/tag/0.0.1
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local
RUN pecl install xdebug-3.1.6 \
&& docker-php-ext-enable xdebug

RUN echo "xdebug.mode=coverage" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
# Xdebug end

WORKDIR /var/www
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ install:
composer install

test:
vendor/bin/phpunit
vendor/bin/phpunit --coverage-text
13 changes: 11 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,23 @@ composer require free-elephants/static-http-client --dev

## Usage

See tests for more examples.

```php
public function test()
{
$stubbedHttpClient = new \FreeElephants\StaticHttpClient\StaticHttpClient(
$responseFactory,
new \FreeElephants\StaticHttpClient\PathResolver\HostnameAwareResolver()
new \FreeElephants\StaticHttpClient\PathResolver\PathBuilderBasedResolver(
new \FreeElephants\StaticHttpClient\PathBuilder\Composite(
new \FreeElephants\StaticHttpClient\PathBuilder\BasePath(__DIR__),
new \FreeElephants\StaticHttpClient\PathBuilder\HostnameAsDirectory(),
new \FreeElephants\StaticHttpClient\PathBuilder\AppendRequestPath(),
new \FreeElephants\StaticHttpClient\PathBuilder\DefaultFileExtension('.json'),
)
)
);

$response = $stubbedHttpClient->sendRequest();
$response = $stubbedHttpClient->sendRequest(new \Nyholm\Psr7\Request('GET', 'https://example.com/foo')); // resolved as __DIR__ . '/example.com/foo.json'
}
```
Loading