DefaultView   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
c 0
b 0
f 0
lcom 0
cbo 2
dl 0
loc 38
ccs 8
cts 8
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getOrder() 0 4 1
A render() 0 19 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