Code Duplication    Length = 24-24 lines in 5 locations

src/HttpAsyncClientDiscovery.php 1 location

@@ 14-37 (lines=24) @@
11
 *
12
 * @author Joel Wurtz <[email protected]>
13
 */
14
final class HttpAsyncClientDiscovery extends ClassDiscovery
15
{
16
    /**
17
     * Finds an HTTP Async Client.
18
     *
19
     * @return HttpAsyncClient
20
     *
21
     * @throws NotFoundException
22
     */
23
    public static function find()
24
    {
25
        try {
26
            $asyncClient = static::findOneByType('Http\Client\HttpAsyncClient');
27
28
            return new $asyncClient();
29
        } catch (DiscoveryFailedException $e) {
30
            throw new NotFoundException(
31
                'No Httplug async clients found. Make sure to install a package providing "php-http/async-client-implementation". Example: "php-http/guzzle6-adapter".',
32
                0,
33
                $e
34
            );
35
        }
36
    }
37
}
38

src/HttpClientDiscovery.php 1 location

@@ 14-37 (lines=24) @@
11
 *
12
 * @author Márk Sági-Kazár <[email protected]>
13
 */
14
final class HttpClientDiscovery extends ClassDiscovery
15
{
16
    /**
17
     * Finds an HTTP Client.
18
     *
19
     * @return HttpClient
20
     *
21
     * @throws NotFoundException
22
     */
23
    public static function find()
24
    {
25
        try {
26
            $client = static::findOneByType('Http\Client\HttpClient');
27
28
            return new $client();
29
        } catch (DiscoveryFailedException $e) {
30
            throw new NotFoundException(
31
                'No Httplug clients found. Make sure to install a package providing "php-http/client-implementation". Example: "php-http/guzzle6-adapter".',
32
                0,
33
                $e
34
            );
35
        }
36
    }
37
}
38

src/MessageFactoryDiscovery.php 1 location

@@ 14-37 (lines=24) @@
11
 *
12
 * @author Márk Sági-Kazár <[email protected]>
13
 */
14
final class MessageFactoryDiscovery extends ClassDiscovery
15
{
16
    /**
17
     * Finds a Message Factory.
18
     *
19
     * @return MessageFactory
20
     *
21
     * @throws NotFoundException
22
     */
23
    public static function find()
24
    {
25
        try {
26
            $messageFactory = static::findOneByType('Http\Message\MessageFactory');
27
28
            return new $messageFactory();
29
        } catch (DiscoveryFailedException $e) {
30
            throw new NotFoundException(
31
                'No factories found. To use Guzzle or Diactoros factories install php-http/message and the chosen message implementation.',
32
                0,
33
                $e
34
            );
35
        }
36
    }
37
}
38

src/StreamFactoryDiscovery.php 1 location

@@ 14-37 (lines=24) @@
11
 *
12
 * @author Михаил Красильников <[email protected]>
13
 */
14
final class StreamFactoryDiscovery extends ClassDiscovery
15
{
16
    /**
17
     * Finds a Stream Factory.
18
     *
19
     * @return StreamFactory
20
     *
21
     * @throws NotFoundException
22
     */
23
    public static function find()
24
    {
25
        try {
26
            $streamFactory = static::findOneByType('Http\Message\StreamFactory');
27
28
            return new $streamFactory();
29
        } catch (DiscoveryFailedException $e) {
30
            throw new NotFoundException(
31
                'No factories found. To use Guzzle or Diactoros factories install php-http/message and the chosen message implementation.',
32
                0,
33
                $e
34
            );
35
        }
36
    }
37
}
38

src/UriFactoryDiscovery.php 1 location

@@ 14-37 (lines=24) @@
11
 *
12
 * @author David de Boer <[email protected]>
13
 */
14
final class UriFactoryDiscovery extends ClassDiscovery
15
{
16
    /**
17
     * Finds a URI Factory.
18
     *
19
     * @return UriFactory
20
     *
21
     * @throws NotFoundException
22
     */
23
    public static function find()
24
    {
25
        try {
26
            $uriFactory = static::findOneByType('Http\Message\UriFactory');
27
28
            return new $uriFactory();
29
        } catch (DiscoveryFailedException $e) {
30
            throw new NotFoundException(
31
                'No factories found. To use Guzzle or Diactoros factories install php-http/message and the chosen message implementation.',
32
                0,
33
                $e
34
            );
35
        }
36
    }
37
}
38