TextResponse::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 2
1
<?php
2
/**
3
 * ownCloud - News
4
 *
5
 * This file is licensed under the Affero General Public License version 3 or
6
 * later. See the COPYING file.
7
 *
8
 * @author Alessandro Cosentino <[email protected]>
9
 * @author Bernhard Posselt <[email protected]>
10
 * @copyright Alessandro Cosentino 2012
11
 * @copyright Bernhard Posselt 2012, 2014
12
 */
13
14
namespace OCA\News\Http;
15
16
use \OCP\AppFramework\Http\Response;
17
18
/**
19
 * Just outputs text to the browser
20
 */
21
class TextResponse extends Response {
22
23
    private $content;
24
25
    /**
26
     * Creates a response that just outputs text
27
     * @param string $content the content that should be written into the file
28
     * @param string $contentType the mimetype. text/ is added automatically so
29
     * only plain or html can be added to get text/plain or text/html
30
     */
31
    public function __construct($content, $contentType='plain'){
32
        $this->content = $content;
33
        $this->addHeader('Content-type', 'text/' . $contentType);
34
    }
35
36
37
    /**
38
     * Simply sets the headers and returns the file contents
39
     * @return string the file contents
40
     */
41
    public function render(){
42
        return $this->content;
43
    }
44
45
46
}
47