Completed
Push — master ( 111a2c...05c48e )
by Márk
07:10 queued 04:34
created

UriFactoryDiscovery   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 38
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A find() 5 5 1

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\Message\UriFactory;
6
7
/**
8
 * Finds a URI Factory.
9
 *
10
 * @author David de Boer <[email protected]>
11
 */
12 View Code Duplication
final class UriFactoryDiscovery extends FactoryDiscovery
13
{
14
    /**
15
     * @var UriFactory
16
     */
17
    protected static $cache;
18
19
    /**
20
     * @var array
21
     */
22
    protected static $classes = [
23
        'guzzle' => [
24
            'class' => 'Http\Message\UriFactory\GuzzleUriFactory',
25
            'condition' => [
26
                'Http\Message\UriFactory\GuzzleUriFactory',
27
                'GuzzleHttp\Psr7\Uri',
28
            ],
29
        ],
30
        'diactoros' => [
31
            'class' => 'Http\Message\UriFactory\DiactorosUriFactory',
32
            'condition' => [
33
                'Http\Message\UriFactory\DiactorosUriFactory',
34
                'Zend\Diactoros\Uri',
35
            ],
36
        ],
37
    ];
38
39
    /**
40
     * Finds a URI Factory.
41
     *
42
     * @return UriFactory
43
     */
44 1
    public static function find()
45
    {
46
        // Override only used for return type declaration
47 1
        return parent::find();
48
    }
49
}
50