Completed
Push — master ( 039dcf...417ea8 )
by Maik
03:08
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 100%

Importance

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

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 12 View Code Duplication
    public function __construct(Url $url, $proto = 'HTTP/1.1', $timeout = 10)
33
    {
34 12
        parent::__construct($url);
35
        
36 12
        $this->setTimeout($timeout);
37 12
        $this->setPath($url->getPath());
38 12
        $this->setProtocol($proto);
39 12
        $this->setQueryString($url->getQueryString());
40 12
        $this->reset();
41 12
        $this->resetHeaders();
42 12
    }
43
    
44
    /**
45
     *
46
     * {@inheritdoc}
47
     * @see \Generics\Streams\HttpStream::request()
48
     */
49 11
    public function request(string $requestType)
50
    {
51 11
        $this->requestImpl($requestType);
52
    }
53
}