Completed
Push — master ( 8fa479...2305de )
by smiley
03:05
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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 5 5 1
A getRequest() 3 3 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;
14
15
use Exception;
16
use Psr\Http\Client\NetworkExceptionInterface;
17
use Psr\Http\Message\RequestInterface;
18
19 View Code Duplication
class NetworkException extends ClientException implements NetworkExceptionInterface{
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...
20
21
	/**
22
	 * @var \Psr\Http\Message\RequestInterface
23
	 */
24
	private $request;
25
26
	/**
27
	 * @param string                             $message
28
	 * @param \Psr\Http\Message\RequestInterface $request
29
	 * @param \Exception|null                    $previous
30
	 */
31
	public function __construct(string $message, RequestInterface $request, Exception $previous = null){
32
		$this->request = $request;
33
34
		parent::__construct($message, 0, $previous);
35
	}
36
37
	/**
38
	 * Returns the request.
39
	 *
40
	 * The request object MAY be a different object from the one passed to ClientInterface::sendRequest()
41
	 *
42
	 * @return \Psr\Http\Message\RequestInterface
43
	 */
44
	public function getRequest():RequestInterface{
45
		return $this->request;
46
	}
47
48
}
49