AttachmentDownloadResponse::render()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
/**
4
 * @author Lukas Reschke <[email protected]>
5
 * @author Thomas Müller <[email protected]>
6
 *
7
 * Mail
8
 *
9
 * This code is free software: you can redistribute it and/or modify
10
 * it under the terms of the GNU Affero General Public License, version 3,
11
 * as published by the Free Software Foundation.
12
 *
13
 * This program is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
 * GNU Affero General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU Affero General Public License, version 3,
19
 * along with this program.  If not, see <http://www.gnu.org/licenses/>
20
 *
21
 */
22
23
namespace OCA\Mail\Http;
24
25
use OCP\AppFramework\Http\DownloadResponse;
26
27
class AttachmentDownloadResponse extends DownloadResponse {
28
	/** @var string  */
29
	private $content;
30
31
	/**
32
	 * Creates a response that prompts the user to download a file which
33
	 * contains the passed string
34
	 * @param string $content the content that should be written into the file
35
	 * @param string $filename the name that the downloaded file should have
36
	 * @param string $contentType the mimetype that the downloaded file should have
37
	 */
38 2
	public function __construct($content, $filename, $contentType){
39 2
		parent::__construct($filename, $contentType);
40 2
		$this->content = $content;
41 2
	}
42
43
	/**
44
	 * Simply sets the headers and returns the file contents
45
	 * @return string the file contents
46
	 */
47 1
	public function render(){
48 1
		return $this->content;
49
	}
50
51
}
52