Skip to content

Commit 44e554e

Browse files
committed
Update README.md
1 parent 5311dea commit 44e554e

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

README.md

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -39,31 +39,31 @@ composer require --dev psr-discovery/http-factory-implementations
3939
## Usage
4040

4141
```php
42-
use PsrDiscovery\Discovery;
42+
use PsrDiscovery\Discover;
4343

4444
// Returns a PSR-17 RequestFactoryInterface instance
45-
$requestFactory = Discovery::httpRequestFactory();
45+
$requestFactory = Discover::httpRequestFactory();
4646

4747
// Returns a PSR-17 ResponseFactoryInterface instance
48-
$responseFactory = Discovery::httpResponseFactory();
48+
$responseFactory = Discover::httpResponseFactory();
4949

5050
// Returns a PSR-17 StreamFactoryInterface instance
51-
$streamFactory = Discovery::httpStreamFactory();
51+
$streamFactory = Discover::httpStreamFactory();
5252

5353
// Returns a PSR-7 RequestInterface instance
5454
$request = $requestFactory->createRequest('GET', 'https://example.com');
5555
```
5656

5757
## Handling Failures
5858

59-
If the library is unable to discover a suitable PSR-17 implementation, the `Discovery::httpRequestFactory()`, `Discovery::httpResponseFactory()` or `Discovery::httpStreamFactory()` discovery methods will simply return `null`. This allows you to handle the failure gracefully, for example by falling back to a default implementation.
59+
If the library is unable to discover a suitable PSR-17 implementation, the `Discover::httpRequestFactory()`, `Discover::httpResponseFactory()` or `Discover::httpStreamFactory()` discovery methods will simply return `null`. This allows you to handle the failure gracefully, for example by falling back to a default implementation.
6060

6161
Example:
6262

6363
```php
64-
use PsrDiscovery\Discovery;
64+
use PsrDiscovery\Discover;
6565

66-
$requestFactory = Discovery::httpRequestFactory();
66+
$requestFactory = Discover::httpRequestFactory();
6767

6868
if ($requestFactory === null) {
6969
// No suitable HTTP RequestFactory implementation was discovered.
@@ -74,20 +74,20 @@ if ($requestFactory === null) {
7474

7575
## Singletons
7676

77-
By default, the `Discovery::httpRequestFactory()`, `Discovery::httpResponseFactory()` or `Discovery::httpStreamFactory()` methods will always return a new instance of the discovered implementation. If you wish to use a singleton instance instead, simply pass `true` to the `$singleton` parameter of the discovery method.
77+
By default, the `Discover::httpRequestFactory()`, `Discover::httpResponseFactory()` or `Discover::httpStreamFactory()` methods will always return a new instance of the discovered implementation. If you wish to use a singleton instance instead, simply pass `true` to the `$singleton` parameter of the discovery method.
7878

7979
Example:
8080

8181
```php
82-
use PsrDiscovery\Discovery;
82+
use PsrDiscovery\Discover;
8383

8484
// $httpResponseFactory1 !== $httpResponseFactory2 (default)
85-
$httpResponseFactory1 = Discovery::httpResponseFactory();
86-
$httpResponseFactory2 = Discovery::httpResponseFactory();
85+
$httpResponseFactory1 = Discover::httpResponseFactory();
86+
$httpResponseFactory2 = Discover::httpResponseFactory();
8787

8888
// $httpResponseFactory1 === $httpResponseFactory2
89-
$httpResponseFactory1 = Discovery::httpResponseFactory(singleton: true);
90-
$httpResponseFactory2 = Discovery::httpResponseFactory(singleton: true);
89+
$httpResponseFactory1 = Discover::httpResponseFactory(singleton: true);
90+
$httpResponseFactory2 = Discover::httpResponseFactory(singleton: true);
9191
```
9292

9393
## Mocking Priority
@@ -101,7 +101,7 @@ The expectation is that these mocking libraries will always be installed as deve
101101
If you wish to prefer a specific implementation over others, you can `prefer()` it by package name:
102102

103103
```php
104-
use PsrDiscovery\Discovery;
104+
use PsrDiscovery\Discover;
105105
use PsrDiscovery\Implementations\Psr17\RequestFactories;
106106

107107
// Prefer the a specific implementation of PSR-17 over others.
@@ -110,7 +110,7 @@ RequestFactories::prefer('nyholm/psr7');
110110
// Return an instance of Nyholm\Psr7\Factory\Psr17Factory,
111111
// or the next available from the list of candidates,
112112
// Returns null if none are discovered.
113-
$factory = Discovery::httpRequestFactory();
113+
$factory = Discover::httpRequestFactory();
114114
```
115115

116116
In this case, this will cause the `httpRequestFactory()` method to return the preferred implementation if it is available, otherwise, it will fall back to the default behavior. The same applies to `httpResponseFactory()` and `httpStreamFactory()` when their relevant classes are configured similarly.
@@ -122,15 +122,15 @@ Note that assigning a preferred implementation will give it priority over the de
122122
If you wish to force a specific implementation and ignore the rest of the discovery candidates, you can `use()` its package name:
123123

124124
```php
125-
use PsrDiscovery\Discovery;
125+
use PsrDiscovery\Discover;
126126
use PsrDiscovery\Implementations\Psr17\ResponseFactories;
127127

128128
// Only discover a specific implementation of PSR-17.
129129
ResponseFactories::use('nyholm/psr7');
130130

131131
// Return an instance of Nyholm\Psr7\Factory\Psr17Factory,
132132
// or null if it is not available.
133-
$factory = Discovery::httpResponseFactory();
133+
$factory = Discover::httpResponseFactory();
134134
```
135135

136136
In this case, this will cause the `httpResponseFactory()` method to return the preferred implementation if it is available, otherwise, it will return `null`. The same applies to `httpRequestFactory()` and `httpStreamFactory()` when their relevant classes are configured similarly.

0 commit comments

Comments
 (0)