Skip to content

Commit c2e2b1c

Browse files
committed
Merge pull request #5 from dbu/fix-examples
fix code examples and further cleanup
2 parents 8094668 + 282c85c commit c2e2b1c

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@
44

55

66
**This is the documentation repository of the HTTP Adapter software components**
7+
8+
Browse the documentation on [Read the Docs](http://php-http.readthedocs.org/).

docs/discovery.md

+12-9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Discovery
22

3-
The discovery service is a set of static classes which allows to find and use installed resources. This is especially useful when used with some virtual packages providing an implementation (`php-http/adapter-implementation`, `psr/http-message-implementation`).
3+
The discovery service is a set of static classes which allows to find and use installed resources. This is useful in libraries that want to offer zero-configuration services and rely only on the virtual packages, e.g. `php-http/adapter-implementation` or `psr/http-message-implementation`.
44

55

66
Currently available discovery services:
@@ -9,14 +9,17 @@ Currently available discovery services:
99
- PSR-7 Message Factory Discovery
1010
- PSR-7 URI Factory Discovery
1111

12-
The principle is always the same: you call a static find method if no explicit implementation was specified. Find will try to locate the service that is enabled. If no service is enabled, an `Http\Discovery\NotFoundException` is thrown.
12+
The principle is always the same: you call the static `find` method on the discovery service if no explicit implementation was specified. The discovery service will try to locate a suitable implementation. If no implementation is found, an `Http\Discovery\NotFoundException` is thrown.
1313

1414

1515
## HTTP Adapter Discovery
1616

1717
This type of discovery finds installed HTTP Adapters.
1818

19-
It is useful to provide zero-configuration for classes relying on an adapter:
19+
Currently available adapters:
20+
21+
- [Guzzle 6](https://github.com/php-http/guzzle6-adapter)
22+
- [Guzzle 5](https://github.com/php-http/guzzle5-adapter)
2023

2124
``` php
2225
use Http\Adapter\HttpAdapter;
@@ -30,9 +33,9 @@ class MyClass
3033
protected $httpAdapter;
3134

3235
/**
33-
* @param HttpAdapter $httpAdapter
36+
* @param HttpAdapter|null $httpAdapter to do HTTP requests.
3437
*/
35-
public function __construct(HttpAdapter $httpAdapter)
38+
public function __construct(HttpAdapter $httpAdapter = null)
3639
{
3740
$this->httpAdapter = $httpAdapter ?: HttpAdapterDiscovery::find();
3841
}
@@ -62,9 +65,9 @@ class MyClass
6265
protected $messageFactory;
6366

6467
/**
65-
* @param MessageFactory $messageFactory
68+
* @param MessageFactory|null $messageFactory to create PSR-7 requests.
6669
*/
67-
public function __construct(MessageFactory $messageFactory)
70+
public function __construct(MessageFactory $messageFactory = null)
6871
{
6972
$this->messageFactory = $messageFactory ?: MessageFactoryDiscovery::find();
7073
}
@@ -93,9 +96,9 @@ class MyClass
9396
protected $uriFactory;
9497

9598
/**
96-
* @param UriFactory $uriFactory
99+
* @param UriFactory|null $uriFactory to create UriInterface instances from strings.
97100
*/
98-
public function __construct(UriFactory $uriFactory)
101+
public function __construct(UriFactory $uriFactory = null)
99102
{
100103
$this->uriFactory = $uriFactory ?: UriFactoryDiscovery::find();
101104
}

0 commit comments

Comments
 (0)