TextDownloadResponse::render()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
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\DownloadResponse;
17
18
19
/**
20
 * Prompts the user to download the a text file
21
 */
22
class TextDownloadResponse extends DownloadResponse {
23
24
    private $content;
25
26
    /**
27
     * Creates a response that prompts the user to download a file which
28
     * contains the passed string
29
     * @param string $content the content that should be written into the file
30
     * @param string $filename the name that the downloaded file should have
31
     * @param string $contentType the mimetype that the downloaded file should
32
     * have
33
     */
34
    public function __construct($content, $filename, $contentType){
35
        parent::__construct($filename, $contentType);
36
        $this->content = $content;
37
    }
38
39
40
    /**
41
     * Simply sets the headers and returns the file contents
42
     * @return string the file contents
43
     */
44
    public function render(){
45
        return $this->content;
46
    }
47
48
49
}
50