Completed
Push — master ( 9d0a53...ecd7bc )
by Maik
01:48
created

HttpsClient   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 36
Duplicated Lines 30.56 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
c 0
b 0
f 0
lcom 0
cbo 3
dl 11
loc 36
ccs 0
cts 14
cp 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 11 11 1
A request() 0 4 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
 * This file is part of the PHP Generics package.
4
 *
5
 * @package Generics
6
 */
7
namespace Generics\Client;
8
9
use Generics\Socket\Url;
10
use Generics\Socket\SecureClientSocket;
11
use Generics\Streams\HttpStream;
12
13
/**
14
 * This class provides a https client connection
15
 *
16
 * @author Maik Greubel <[email protected]>
17
 */
18
class HttpsClient extends SecureClientSocket implements HttpStream
19
{
20
    use HttpClientTrait;
21
    
22
    /**
23
     * Create a new https client
24
     *
25
     * @param Url $url
26
     *            The url for http request
27
     * @param string $proto
28
     *            The protocol to use (default = HTTP/1.1)
29
     * @param integer $timeout
30
     *            Optional timeout for request (default = 10 seconds)
31
     */
32 View Code Duplication
    public function __construct(Url $url, $proto = 'HTTP/1.1', $timeout = 10)
33
    {
34
        parent::__construct($url);
35
        
36
        $this->setTimeout($timeout);
37
        $this->setPath($url->getPath());
38
        $this->setProtocol($proto);
39
        $this->setQueryString($url->getQueryString());
40
        $this->reset();
41
        $this->resetHeaders();
42
    }
43
    
44
    /**
45
     *
46
     * {@inheritdoc}
47
     * @see \Generics\Streams\HttpStream::request()
48
     */
49
    public function request(string $requestType)
50
    {
51
        $this->requestImpl($requestType);
52
    }
53
}