RESTClientResponse   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 0
dl 0
loc 32
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A get_header() 0 3 1
1
<?php
2
3
/**
4
 * This file is part of Communique.
5
 * 
6
 * @author Robert Main
7
 * @package Communique
8
 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace Communique;
15
16
/**
17
 * REST Response
18
 *
19
 * This class is used to encapsulate the response from the API. Whilst it is used internally, it is also
20
 * made available to response interceptors for reading from and/or writing to.
21
 * 
22
 */
23
class RESTClientResponse {
24
25
	/** @var int The HTTP status code returned by the server */
26
	public $status;
27
28
	/** @var Mixed The response payload from the server */
29
	public $payload;
30
31
	/** @var Array An array of headers returned by the server */
32
	public $headers;
33
34
	/**
35
	 * Response object constructor. Response properties should be set here (rather than just setting the object properties directly).
36
	 * @param int    $status  The HTTP status code of the request
37
	 * @param mixed  $payload The response issued by the API
38
	 * @param array  $headers Any headers returned by the server
39
	 */
40
	public function __construct($status, $payload, array $headers = array()) {
41
		$this->status = $status;
42
		$this->payload = $payload;
43
		$this->headers = $headers;
44
	}
45
46
	/**
47
	 * Searches the request headers by key
48
	 * @param  String $key The key of the header to return
49
	 * @return mixed       The value of the requested header
50
	 */
51
	public function get_header($key) {
52
		return $this->headers[$key];
53
	}
54
}