GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Passed
Push — master ( b1adde...186741 )
by Marius
11:19
created

RawHttpRequest   A

Complexity

Total Complexity 27

Size/Duplication

Total Lines 118
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 85%

Importance

Changes 0
Metric Value
dl 0
loc 118
ccs 51
cts 60
cp 0.85
rs 10
c 0
b 0
f 0
wmc 27
lcom 1
cbo 1

10 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 3
A setRawVars() 0 9 3
B getRawVars() 0 23 6
A getRawVar() 0 8 3
A getVars() 0 12 3
A hasVar() 0 6 2
A hasRawVar() 0 4 2
A getVar() 0 7 2
A getRawInput() 0 3 1
A constructRawVars() 0 8 2
1
<?php
2
/**
3
 * @package presentation
4
 * @subpackage requests
5
 * @author marius orcsik <[email protected]>
6
 * @date 2011.08.11
7
 */
8
namespace vsc\presentation\requests;
9
10
class RawHttpRequest extends RwHttpRequest {
11
	protected $aRawVars = [];
12
	protected $sRawInput;
13
14 1
	public function __construct() {
15 1
		parent::__construct();
16
17 1
		if (isset($_SERVER) && !$this->isGet()) {
18 1
			$this->constructRawVars();
19
		}
20 1
	}
21
22
	// this seems quite unsafe
23 1
	public function setRawVars($aVars) {
24 1
		if (is_array($aVars)) {
25 1
			if (is_array($this->aRawVars)) {
26
				$this->aRawVars = array_merge($aVars, $this->aRawVars);
27
			} else {
28 1
				$this->aRawVars = $aVars;
29
			}
30
		}
31 1
	}
32
33 3
	public function getRawVars() {
34 3
		if (!empty($this->aRawVars)) {
35
			return $this->aRawVars;
36
		}
37 3
		$sContentType = $this->getContentType();
38
39 3
		$vars = array();
40 3
		switch ($sContentType) {
41 3
		case 'application/x-www-form-urlencoded':
42
			parse_str($this->sRawInput, $vars);
43
			break;
44 3
		case 'application/json':
45 1
			$vars = json_decode($this->sRawInput, true);
46 1
			break;
47 2
		case 'application/xml':
48
		default:
49 2
			break;
50
		}
51 3
		if (!empty ($vars)) {
52 1
			$this->aRawVars = $vars;
0 ignored issues
show
Documentation Bug introduced by
It seems like $vars of type * is incompatible with the declared type array of property $aRawVars.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
53
		}
54 3
		return $this->aRawVars;
55
	}
56
57
	/**
58
	 * @param string $sVarName
59
	 * @return mixed
60
	 */
61 1
	public function getRawVar($sVarName) {
62 1
		$aRawVars = $this->getRawVars();
63 1
		if (is_array($aRawVars) && array_key_exists($sVarName, $aRawVars)) {
64 1
			return self::getDecodedVar($aRawVars[$sVarName]);
65
		} else {
66
			return null;
67
		}
68
	}
69
70 1
	public function getVars() {
71 1
		$aRawVars = $this->getRawVars();
72 1
		$aParentVars = parent::getVars();
73 1
		if (!is_array($aRawVars)) {
74
			return parent::getVars();
75
		} else {
76 1
			if (is_array($aParentVars)) {
77 1
				return array_merge($aRawVars, $aParentVars);
78
			}
79
			return $aRawVars;
80
		}
81
	}
82
83 2
	public function hasVar($sVarName) {
84
		return (
85 2
			$this->hasRawVar($sVarName) ||
86 2
			parent::hasVar($sVarName)
87
		);
88
	}
89
90 1
	public function hasRawVar($sVarName) {
91 1
		$aRawVars = $this->getRawVars();
92 1
		return (is_array($aRawVars) && array_key_exists($sVarName, $aRawVars));
93
	}
94
95
	/**
96
	 * @param string $sVarName
97
	 * @return mixed
98
	 */
99 1
	public function getVar($sVarName) {
100 1
		$mValue = parent::getVar($sVarName);
101 1
		if (!$mValue) {
102 1
			$mValue = $this->getRawVar($sVarName);
103
		}
104 1
		return $mValue;
105
	}
106
107
	/**
108
	 * @return string
109
	 */
110
	protected function getRawInput() {
111
		return file_get_contents('php://input');
112
	}
113
114
	/**
115
	 * @todo this has to be moved in the rw url handler
116
	 * @param string $sRawInput
0 ignored issues
show
Documentation introduced by
Should the type for parameter $sRawInput not be string|null?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
117
	 * @return void
118
	 */
119 5
	protected function constructRawVars($sRawInput = null) {
120 5
		if (is_null($sRawInput)) {
121 5
			$this->sRawInput = $this->getRawInput();
122
		} else {
123 3
			$this->sRawInput = $sRawInput;
124
		}
125 5
		$this->aRawVars = null;
0 ignored issues
show
Documentation Bug introduced by
It seems like null of type null is incompatible with the declared type array of property $aRawVars.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
126 5
	}
127
}
128