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

HttpClients::findOneByType()   C

Complexity

Conditions 7
Paths 5

Size

Total Lines 23
Code Lines 15

Duplication

Lines 16
Ratio 69.57 %

Code Coverage

Tests 0
CRAP Score 56

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 16
loc 23
ccs 0
cts 22
cp 0
rs 6.7272
cc 7
eloc 15
nc 5
nop 1
crap 56
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