DefaultView::render()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 19
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 19
ccs 6
cts 6
cp 1
rs 9.4285
cc 2
eloc 5
nc 2
nop 3
crap 2
1
<?php
2
namespace Nkey\Caribu\Mvc\View;
3
4
use \Nkey\Caribu\Mvc\Controller\Response;
5
use \Nkey\Caribu\Mvc\Controller\Request;
6
use \Nkey\Caribu\Mvc\View\AbstractView;
7
8
/**
9
 * This is the default view class
10
 *
11
 *
12
 * It provides the lowest level of view rending possible.
13
 * The render function determines the output type and either
14
 * renders html or let the body content untouched.
15
 *
16
 * @applyTo(controller=any,action=any)
17
 *
18
 * @author Maik Greubel <[email protected]>
19
 *
20
 *         This file is part of Caribu MVC package
21
 */
22
class DefaultView extends AbstractView
23
{
24
25
    /**
26
     * (non-PHPdoc)
27
     *
28
     * @see \Nkey\Caribu\Mvc\View\AbstractView::getOrder()
29
     */
30 29
    public function getOrder()
31
    {
32 29
        return 0;
33
    }
34
35
    /**
36
     * (non-PHPdoc)
37
     *
38
     * @see \Nkey\Caribu\Mvc\View\AbstractView::render()
39
     */
40 19
    public function render(Response &$response, Request $request, $parameters = array())
41
    {
42 19
        if ($response->getType() == 'text/html') {
43 17
            $html = sprintf("
44
<!DOCTYPE html>
45
<html>
46
<head>
47
<title>%s</title>
48
</head>
49
50
<body>
51
%s
52
</body>
53
54 17
</html>", $response->getTitle(), $response->getBody());
55
            
56 17
            $response->setBody($html);
57
        }
58 19
    }
59
}
60