RequestOptions   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 80
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 0
dl 80
loc 80
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 11 11 1
A getUrl() 4 4 1
A getRequestTimeout() 4 4 1
A getFollowRedirect() 4 4 1
A getBasicAuth() 4 4 1
A needsBasicAuth() 4 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
namespace DjThossi\SmokeTestingPhp\Options;
3
4
use DjThossi\SmokeTestingPhp\ValueObject\BasicAuth;
5
use DjThossi\SmokeTestingPhp\ValueObject\FollowRedirect;
6
use DjThossi\SmokeTestingPhp\ValueObject\RequestTimeout;
7
use DjThossi\SmokeTestingPhp\ValueObject\Url;
8
9 View Code Duplication
class RequestOptions
10
{
11
    /**
12
     * @var Url
13
     */
14
    private $url;
15
16
    /**
17
     * @var RequestTimeout
18
     */
19
    private $requestTimeout;
20
21
    /**
22
     * @var FollowRedirect
23
     */
24
    private $followRedirect;
25
26
    /**
27
     * @var BasicAuth|null
28
     */
29
    private $basicAuth;
30
31
    /**
32
     * @param $url
33
     * @param RequestTimeout $requestTimeout
34
     * @param FollowRedirect $followRedirect
35
     * @param BasicAuth|null $basicAuth
36
     */
37
    public function __construct(
38
        Url $url,
39
        RequestTimeout $requestTimeout,
40
        FollowRedirect $followRedirect,
41
        BasicAuth $basicAuth = null
42
    ) {
43
        $this->url = $url;
44
        $this->requestTimeout = $requestTimeout;
45
        $this->followRedirect = $followRedirect;
46
        $this->basicAuth = $basicAuth;
47
    }
48
49
    /**
50
     * @return Url
51
     */
52
    public function getUrl()
53
    {
54
        return $this->url;
55
    }
56
57
    /**
58
     * @return RequestTimeout
59
     */
60
    public function getRequestTimeout()
61
    {
62
        return $this->requestTimeout;
63
    }
64
65
    /**
66
     * @return FollowRedirect
67
     */
68
    public function getFollowRedirect()
69
    {
70
        return $this->followRedirect;
71
    }
72
73
    /**
74
     * @return BasicAuth|null
75
     */
76
    public function getBasicAuth()
77
    {
78
        return $this->basicAuth;
79
    }
80
81
    /**
82
     * @return bool
83
     */
84
    public function needsBasicAuth()
85
    {
86
        return $this->basicAuth !== null;
87
    }
88
}
89