Completed
Push — master ( 988ea9...868c80 )
by smiley
07:26
created

NetworkException   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 30
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
dl 30
loc 30
rs 10
c 0
b 0
f 0
wmc 2
lcom 0
cbo 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
 * Class NetworkException
4
 *
5
 * @filesource   NetworkException.php
6
 * @created      10.09.2018
7
 * @package      chillerlan\HTTP
8
 * @author       smiley <[email protected]>
9
 * @copyright    2018 smiley
10
 * @license      MIT
11
 */
12
13
namespace chillerlan\HTTP\Psr18;
14
15
use Exception;
16
use Psr\Http\Client\NetworkExceptionInterface;
17
use Psr\Http\Message\RequestInterface;
18
19
/**
20
 * @codeCoverageIgnore
21
 */
22
class NetworkException extends ClientException implements NetworkExceptionInterface{
23
24
	/**
25
	 * @var \Psr\Http\Message\RequestInterface
26
	 */
27
	private RequestInterface $request;
0 ignored issues
show
Bug introduced by
This code did not parse for me. Apparently, there is an error somewhere around this line:

Syntax error, unexpected T_STRING, expecting T_FUNCTION or T_CONST
Loading history...
28
29
	/**
30
	 * @param string                             $message
31
	 * @param \Psr\Http\Message\RequestInterface $request
32
	 * @param \Exception|null                    $previous
33
	 */
34
	public function __construct(string $message, RequestInterface $request, Exception $previous = null){
35
		$this->request = $request;
36
37
		parent::__construct($message, 0, $previous);
38
	}
39
40
	/**
41
	 * Returns the request.
42
	 *
43
	 * The request object MAY be a different object from the one passed to ClientInterface::sendRequest()
44
	 *
45
	 * @return \Psr\Http\Message\RequestInterface
46
	 */
47
	public function getRequest():RequestInterface{
48
		return $this->request;
49
	}
50
51
}
52