UriFactoryDiscovery   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 2
dl 20
loc 20
ccs 5
cts 5
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A find() 10 10 2

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace Http\Discovery;
4
5
use Http\Discovery\Exception\DiscoveryFailedException;
6
use Http\Message\UriFactory;
7
8
/**
9
 * Finds a URI Factory.
10
 *
11
 * @author David de Boer <[email protected]>
12
 *
13
 * @deprecated This will be removed in 2.0. Consider using Psr17FactoryDiscovery.
14
 */
15 View Code Duplication
final class UriFactoryDiscovery extends ClassDiscovery
16
{
17
    /**
18
     * Finds a URI Factory.
19
     *
20
     * @return UriFactory
21
     *
22
     * @throws Exception\NotFoundException
23
     */
24 2
    public static function find()
25
    {
26
        try {
27 2
            $uriFactory = static::findOneByType(UriFactory::class);
28 1
        } catch (DiscoveryFailedException $e) {
29 1
            throw new NotFoundException('No uri 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($uriFactory);
33
    }
34
}
35