Passed
Push — master ( b74ffc...b3c755 )
by Fabio
06:39
created

THttpResponseAdapter::setResponseData()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 1
c 1
b 0
f 1
nc 1
nop 1
dl 0
loc 3
ccs 0
cts 0
cp 0
crap 2
rs 10
1
<?php
2
/**
3
 * THttpResponseAdatper class
4
 *
5
 * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
6
 * @link https://github.com/pradosoft/prado
7
 * @license https://github.com/pradosoft/prado/blob/master/LICENSE
8
 * @package Prado\Web
9
 */
10
11
namespace Prado\Web;
12
13
use Prado\Exceptions\TInvalidOperationException;
14
15
/**
16
 * THttpResponseAdapter class.
17
 *
18
 * THttpResponseAdapter allows the base http response class to change behavior
19
 * without change the class hierarchy.
20
 *
21
 * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
22
 * @package Prado\Web
23
 * @since 3.0
24
 */
25
class THttpResponseAdapter extends \Prado\TApplicationComponent
26
{
27
	/**
28
	 * @var THttpResponse the response object the adapter is attached.
29
	 */
30
	private $_response;
31
32
	/**
33
	 * Constructor. Attach a response to be adapted.
34
	 * @param THttpResponse $response the response object the adapter is to attach to.
35
	 */
36
	public function __construct($response)
37
	{
38
		$this->_response = $response;
39
		parent::__construct();
40
	}
41
42
	/**
43
	 * @return THttpResponse the response object adapted.
44
	 */
45
	public function getResponse()
46
	{
47
		return $this->_response;
48
	}
49
50
	/**
51
	 * This method is invoked when the response flushes the content and headers.
52
	 * Default implementation calls the attached response flushContent method.
53
	 * @param bool $continueBuffering
54
	 */
55
	public function flushContent($continueBuffering = true)
56
	{
57
		$this->_response->flushContent($continueBuffering);
58
	}
59
60
	/**
61
	 * This method is invoked when the response is to redirect to another page.
62
	 * @param string $url new url to redirect to.
63
	 */
64
	public function httpRedirect($url)
65
	{
66
		$this->_response->httpRedirect($url);
67
	}
68
69
	/**
70
	 * This method is invoked when a new HtmlWriter needs to be created.
71
	 * Default implementation calls the attached response createNewHtmlWriter method.
72
	 * @param string $type type of the HTML writer to be created.
73
	 * @param \Prado\IO\ITextWriter $writer the writer responsible for holding the content.
74
	 */
75
	public function createNewHtmlWriter($type, $writer)
76
	{
77
		return $this->_response->createNewHtmlWriter($type, $writer);
78
	}
79
80
	/**
81
	 * @throws TInvalidOperationException
82
	 */
83
	public function setResponseData($data)
0 ignored issues
show
Unused Code introduced by
The parameter $data is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

83
	public function setResponseData(/** @scrutinizer ignore-unused */ $data)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
84
	{
85
		throw new TInvalidOperationException('httpresponse_responsedata_method_unavailable', __METHOD__);
86
	}
87
88
	/**
89
	 * @throws TInvalidOperationException
90
	 */
91
	public function getResponseData()
92
	{
93
		throw new TInvalidOperationException('httpresponse_responsedata_method_unavailable', __METHOD__);
94
	}
95
}
96