RequestSentEvent   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 89
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 8
lcom 1
cbo 1
dl 89
loc 89
ccs 22
cts 22
cp 1
rs 10
c 0
b 0
f 0

8 Methods

Rating   Name   Duplication   Size   Complexity  
A getRequest() 4 4 1
A __construct() 10 10 1
A setRequest() 4 4 1
A getResponse() 4 4 1
A setResponse() 4 4 1
A hasException() 4 4 1
A getException() 4 4 1
A setException() 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
3
/*
4
 * This file is part of the Ivory Http Adapter package.
5
 *
6
 * (c) Eric GELOEN <[email protected]>
7
 *
8
 * For the full copyright and license information, please read the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Ivory\HttpAdapter\Event;
13
14
use Ivory\HttpAdapter\HttpAdapterException;
15
use Ivory\HttpAdapter\HttpAdapterInterface;
16
use Ivory\HttpAdapter\Message\InternalRequestInterface;
17
use Ivory\HttpAdapter\Message\ResponseInterface;
18
19
/**
20
 * @author GeLo <[email protected]>
21
 */
22 View Code Duplication
class RequestSentEvent extends AbstractEvent
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in 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...
23
{
24
    /**
25
     * @var InternalRequestInterface
26
     */
27
    private $request;
28
29
    /**
30
     * @var ResponseInterface|null
31
     */
32
    private $response;
33
34
    /**
35
     * @var HttpAdapterException|null
36
     */
37
    private $exception;
38
39
    /**
40
     * @param HttpAdapterInterface     $httpAdapter
41
     * @param InternalRequestInterface $request
42
     * @param ResponseInterface        $response
43
     */
44 171
    public function __construct(
45
        HttpAdapterInterface $httpAdapter,
46
        InternalRequestInterface $request,
47
        ResponseInterface $response
48
    ) {
49 171
        parent::__construct($httpAdapter);
50
51 171
        $this->setRequest($request);
52 171
        $this->setResponse($response);
53 171
    }
54
55
    /**
56
     * @return InternalRequestInterface
57
     */
58 117
    public function getRequest()
59
    {
60 117
        return $this->request;
61
    }
62
63
    /**
64
     * @param InternalRequestInterface $request
65
     */
66 171
    public function setRequest(InternalRequestInterface $request)
67
    {
68 171
        $this->request = $request;
69 171
    }
70
71
    /**
72
     * @return ResponseInterface|null
73
     */
74 135
    public function getResponse()
75
    {
76 135
        return $this->response;
77
    }
78
79
    /**
80
     * @param ResponseInterface|null $response
81
     */
82 171
    public function setResponse(ResponseInterface $response = null)
83
    {
84 171
        $this->response = $response;
85 171
    }
86
87
    /**
88
     * @return bool
89
     */
90 90
    public function hasException()
91
    {
92 90
        return $this->exception !== null;
93
    }
94
95
    /**
96
     * @return HttpAdapterException|null
97
     */
98 54
    public function getException()
99
    {
100 54
        return $this->exception;
101
    }
102
103
    /**
104
     * @param HttpAdapterException|null $exception
105
     */
106 45
    public function setException(HttpAdapterException $exception = null)
107
    {
108 45
        $this->exception = $exception;
109 45
    }
110
}
111