StreamFactoryDiscovery::find()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10

Duplication

Lines 10
Ratio 100 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
dl 10
loc 10
ccs 5
cts 5
cp 1
rs 9.9332
c 0
b 0
f 0
cc 2
nc 2
nop 0
crap 2
1
<?php
2
3
namespace Http\Discovery;
4
5
use Http\Discovery\Exception\DiscoveryFailedException;
6
use Http\Message\StreamFactory;
7
8
/**
9
 * Finds a Stream Factory.
10
 *
11
 * @author Михаил Красильников <[email protected]>
12
 *
13
 * @deprecated This will be removed in 2.0. Consider using Psr17FactoryDiscovery.
14
 */
15 View Code Duplication
final class StreamFactoryDiscovery extends ClassDiscovery
16
{
17
    /**
18
     * Finds a Stream Factory.
19
     *
20
     * @return StreamFactory
21
     *
22
     * @throws Exception\NotFoundException
23
     */
24 2
    public static function find()
25
    {
26
        try {
27 2
            $streamFactory = static::findOneByType(StreamFactory::class);
28 1
        } catch (DiscoveryFailedException $e) {
29 1
            throw new NotFoundException('No stream factories found. To use Guzzle, Diactoros or Slim Framework factories install php-http/message and the chosen message implementation.', 0, $e);
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...
30
        }
31
32 1
        return static::instantiateClass($streamFactory);
33
    }
34
}
35