Completed
Push — master ( 16c8a5...965897 )
by Michael
02:58
created

ServerResponseException::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 6
ccs 4
cts 4
cp 1
rs 9.4285
cc 1
eloc 3
nc 1
nop 2
crap 1
1
<?php
2
3
/**
4
 * This file is part of the miBadger package.
5
 *
6
 * @author Michael Webbers <[email protected]>
7
 * @license http://opensource.org/licenses/Apache-2.0 Apache v2 License
8
 * @version 1.0.0
9
 */
10
11
namespace miBadger\Http;
12
13
/**
14
 * The server response exception class.
15
 *
16
 * @since 1.0.0
17
 */
18
class ServerResponseException extends \Exception
19
{
20
	/** @var ServerResponse The server response. */
21
	private $serverResponse;
22
23
	/**
24
	 * Contract a server response exception with the gieven server response.
25
	 *
26
	 * @param ServerResponse $serverResponse
27
	 * @param \Exception|null $exception = null
28
	 */
29 2
	public function __construct(ServerResponse $serverResponse, \Exception $exception = null)
30
	{
31 2
		parent::__construct($serverResponse->getReasonPhrase(), $serverResponse->getStatusCode(), $exception);
32
33 2
		$this->serverResponse = $serverResponse;
34 2
	}
35
36
	/**
37
	 * Returns the server response.
38
	 *
39
	 * @return ServerResponse the server response.
40
	 */
41 1
	public function getServerResponse()
42
	{
43 1
		return $this->serverResponse;
44
	}
45
}
46