Completed
Pull Request — master (#355)
by Victor
02:52
created

Request::server()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 3
ccs 0
cts 2
cp 0
rs 10
cc 2
eloc 2
nc 2
nop 1
crap 6
1
<?php
2
3
/**
4
 * @author Victor Dubiniuk <[email protected]>
5
 *
6
 * @copyright Copyright (c) 2015, ownCloud, Inc.
7
 * @license AGPL-3.0
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 Owncloud\Updater\Http;
24
25
class Request {
26
	protected $vars;
27
28 4
	public function __construct($vars = []){
29 4
		$this->vars = $vars;
30 4
	}
31
32
	/**
33
	 * @param string $name
34
	 * @return mixed
35
	 */
36 4
	public function postParameter($name){
37 4
		return isset($this->vars['post'][$name]) ? $this->vars['post'][$name] : null;
38
	}
39
40
	/**
41
	 * @param string $name
42
	 * @return mixed
43
	 */
44
	public function header($name) {
45
		$name = strtoupper($name);
46
		return isset($this->vars['headers']['HTTP_'.$name]) ? $this->vars['headers']['HTTP_'.$name] : null;
47
	}
48
49
	/**
50
	 * @param string $name
51
	 * @return mixed
52
	 */
53
	public function server($name){
54
		return isset($this->vars['headers']['HTTP_'.$name]) ? $this->vars['headers']['HTTP_'.$name] : null;
55
	}
56
57
58
}
59
60