Completed
Pull Request — master (#58)
by Tobias
07:12 queued 05:05
created

HttpClients   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 29
Duplicated Lines 55.17 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 7
c 1
b 0
f 1
lcom 0
cbo 0
dl 16
loc 29
ccs 0
cts 22
cp 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
C findOneByType() 16 23 7

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\FallbackStrategy;
4
5
/**
6
 * Find common HTTP clients.
7
 *
8
 * @author Tobias Nyholm <[email protected]>
9
 */
10
class HttpClients implements FallbackStrategy
11
{
12
    /**
13
     * {@inheritdoc}
14
     */
15
    public static function findOneByType($type)
16
    {
17
        switch ($type) {
18 View Code Duplication
            case 'Http\Client\HttpAsyncClient':
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
19
                $clients = ['Http\Adapter\Guzzle6\Client'];
20
                foreach ($clients as $class) {
21
                    if (class_exists($class)) {
22
                        return $class;
23
                    }
24
                }
25
                break;
26 View Code Duplication
            case 'Http\Client\HttpClient':
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
27
                $clients = ['Http\Adapter\Guzzle6\Client', 'Http\Adapter\Guzzle5\Client'];
28
                foreach ($clients as $class) {
29
                    if (class_exists($class)) {
30
                        return $class;
31
                    }
32
                }
33
                break;
34
        }
35
36
        return false;
37
    }
38
}
39