Completed
Pull Request — master (#94)
by Fabien
08:01
created

PluginClientFactoryDiscovery::find()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 14
Code Lines 9

Duplication

Lines 14
Ratio 100 %

Importance

Changes 0
Metric Value
dl 14
loc 14
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 9
nc 2
nop 0
1
<?php
2
3
namespace Http\Discovery;
4
5
use Http\Client\Common\PluginClientFactoryInterface;
6
use Http\Discovery\Exception\DiscoveryFailedException;
7
8
/**
9
 * Finds a PluginClientFactoryInterface implementation.
10
 *
11
 * @author Fabien Bourigault <[email protected]>
12
 */
13 View Code Duplication
final class PluginClientFactoryDiscovery extends ClassDiscovery
14
{
15
    /**
16
     * Finds a PluginClientFactoryInterface implementation.
17
     *
18
     * @return PluginClientFactoryInterface
19
     *
20
     * @throws Exception\NotFoundException
21
     */
22
    public static function find()
23
    {
24
        try {
25
            $client = static::findOneByType(PluginClientFactoryInterface::class);
26
        } catch (DiscoveryFailedException $e) {
27
            throw new NotFoundException(
0 ignored issues
show
Deprecated Code introduced by
The class Http\Discovery\NotFoundException has been deprecated with message: since since version 1.0, and will be removed in 2.0. Use {@link \Http\Discovery\Exception\NotFoundException} instead.

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.

Loading history...
28
                'No HTTPlug plugin clients found. Make sure to install "php-http/client-common".',
29
                0,
30
                $e
31
            );
32
        }
33
34
        return static::instantiateClass($client);
35
    }
36
}
37