ExportResponse::__construct()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
cc 2
eloc 9
nc 2
nop 1
dl 0
loc 10
ccs 0
cts 10
cp 0
crap 6
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace OCA\Bookmarks\Controller\Lib;
4
5
use OCP\AppFramework\Http\Response;
6
7
class ExportResponse extends Response {
8
9
	private $returnstring;
10
11
	public function __construct($returnstring) {
12
		$user_name = trim(\OCP\User::getDisplayName()) != '' ?
13
				\OCP\User::getDisplayName() : \OCP\User::getUser();
14
		$export_name = '"ownCloud Bookmarks (' . $user_name . ') (' . date('Y-m-d') . ').html"';
15
		$this->addHeader("Cache-Control", "private");
16
		$this->addHeader("Content-Type", " application/stream");
17
		$this->addHeader("Content-Length", strlen($returnstring));
18
		$this->addHeader("Content-Disposition", "attachment; filename=" . $export_name);
19
		$this->returnstring = $returnstring;
20
	}
21
22
	public function render() {
23
		return $this->returnstring;
24
	}
25
26
}