Completed
Push — master ( 275b0e...27ac7e )
by Timothy
02:35
created

HttpView::setStatusCode()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 1
Metric Value
c 1
b 1
f 1
dl 0
loc 6
rs 9.4286
cc 1
eloc 4
nc 1
nop 1
1
<?php
0 ignored issues
show
Coding Style introduced by
File has mixed line endings; this may cause incorrect results
Loading history...
2
/**
3
 * Ion
4
 *
5
 * Building blocks for web development
6
 *
7
 * @package     Ion
8
 * @author      Timothy J. Warren
9
 * @copyright   Copyright (c) 2015 - 2016
10
 * @license     MIT
11
 */
12
13
namespace Aviat\Ion\View;
14
15
use Aura\Web\ResponseSender;
16
17
use Aviat\Ion\View as BaseView;
18
19
/**
20
 * Base view class for Http output
21
 */
22
class HttpView extends BaseView {
23
24
	/**
25
	 * Do a redirect
26
	 *
27
	 * @param string $url
28
	 * @param int $code
29
	 * @return void
30
	 */
31
	public function redirect($url, $code)
32
	{
33
		$this->response->redirect->to($url, $code);
34
	}
35
36
	/**
37
	 * Set the status code of the request
38
	 *
39
	 * @param int $code
40
	 * @return HttpView
41
	 */
42
	public function setStatusCode($code)
43
	{
44
		$this->response->status->setCode($code);
45
		$this->response->status->setVersion(1.1);
46
		return $this;
47
	}
48
49
	/**
50
	 * Send output to client
51
	 */
52
	public function send()
53
	{
54
		$this->hasRendered = TRUE;
55
		$this->output();
56
	}
57
58
	/**
59
	 * Send the appropriate response
60
	 *
61
	 * @return void
62
	 */
63
	protected function output()
64
	{
65
		$content =& $this->response->content;
66
		$content->set($this->output);
67
		$content->setType($this->contentType);
68
		$content->setCharset('utf-8');
69
70
		$sender = new ResponseSender($this->response);
71
		$sender->__invoke();
72
	}
73
74
}