germania-kg / mergequery_urifactory
URI factory decorator for merging query parameters
1.0.3
2021-01-11 13:39 UTC
Requires
- php: ^7.2|^8.0
- psr/http-factory: ^1.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.0
- nyholm/psr7: ^1.3
- php-coveralls/php-coveralls: ^2.0
- phpspec/prophecy-phpunit: ^2.0
- phpstan/phpstan: ^0.12
- phpunit/phpunit: ^9.0
This package is auto-updated.
Last update: 2024-11-11 22:33:15 UTC
README
Germania KG ยท MergeQueryUriFactory
Installation
$ composer require germania-kg/mergequery_urifactory
Usage:
The MergeQueryUriFactoryDecorator adds a createUriMergeQuery
method to any given PSR-17 UriFactory. It also itself implements Psr\Http\Message\UriFactoryInterface
and can also be used as callable
.
The createUriMergeQuery
accepts both string and UriInterface URIs.
<?php use Germania\MergeQueryUriFactory\MergeQueryUriFactoryDecorator; use Nyholm\Psr7\Factory\Psr17Factory; $decoratee = new Psr17Factory(); $uri_factory = new MergeQueryUriFactoryDecorator( $decoratee ); // You know the UriFactoryInterface: $uri = $uri_factory->createUri( 'http://httpbin.org' ); // Programmatically merge query parameters, // either to a string or UriInterface: $uri2 = $uri_factory->createUriMergeQuery( 'http://httpbin.org', ['foo' => 'bar']); $uri3 = $uri_factory->createUriMergeQuery( $uri, ['foo' => 'bar']); echo $uri3; // http://httpbin.org?foo=bar