File Request.php
has 442 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* @author Bart Visscher <bartv@thisnet.nl>
* @author Bernhard Posselt <dev@bernhard-posselt.com>
* @author Joas Schilling <coding@schilljs.com>
Request
has 34 functions (exceeds 20 allowed). Consider refactoring. Open
class Request implements ArrayAccess, Countable, IRequest {
public const USER_AGENT_IE = '/(MSIE)|(Trident)/';
public const USER_AGENT_IE_8 = '/MSIE 8.0/';
// Microsoft Edge User Agent from https://msdn.microsoft.com/en-us/library/hh869301(v=vs.85).aspx
public const USER_AGENT_MS_EDGE = '/^Mozilla\/5\.0 \([^)]+\) AppleWebKit\/[0-9.]+ \(KHTML, like Gecko\) Chrome\/[0-9.]+ (Mobile Safari|Safari)\/[0-9.]+ Edge\/[0-9.]+$/';
Function getRemoteAddress
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
public function getRemoteAddress() {
$remoteAddress = $this->server['REMOTE_ADDR'] ?? '';
$trustedProxies = $this->config->getSystemValue('trusted_proxies', []);
if (\is_array($trustedProxies) && \in_array($remoteAddress, $trustedProxies)) {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function getRawPathInfo
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public function getRawPathInfo() {
$requestUri = $this->server['REQUEST_URI'] ?? '';
// remove too many leading slashes - can be caused by reverse proxy configuration
if (\strpos($requestUri, '/') === 0) {
$requestUri = '/' . \ltrim($requestUri, '/');
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function decodeContent
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
protected function decodeContent() {
if ($this->contentDecoded) {
return;
}
$params = [];
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method getRawPathInfo
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getRawPathInfo() {
$requestUri = $this->server['REQUEST_URI'] ?? '';
// remove too many leading slashes - can be caused by reverse proxy configuration
if (\strpos($requestUri, '/') === 0) {
$requestUri = '/' . \ltrim($requestUri, '/');
Function getRequestUri
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public function getRequestUri() {
$uri = $this->server['REQUEST_URI'] ?? '';
// remove too many leading slashes - can be caused by reverse proxy configuration
if (\strpos($uri, '/') === 0) {
$uri = '/' . \ltrim($uri, '/');
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function getInsecureServerHost
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function getInsecureServerHost() {
$host = 'localhost';
if (isset($this->server['HTTP_X_FORWARDED_HOST'])) {
if (\strpos($this->server['HTTP_X_FORWARDED_HOST'], ',') !== false) {
$parts = \explode(',', $this->server['HTTP_X_FORWARDED_HOST']);
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method __construct
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
array $vars= [],
ISecureRandom $secureRandom = null,
IConfig $config = null,
CsrfTokenManager $csrfTokenManager = null,
$stream = 'php://input'
Function getServerProtocol
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function getServerProtocol() {
if ($this->config->getSystemValue('overwriteprotocol') !== ''
&& $this->isOverwriteCondition('protocol')) {
return $this->config->getSystemValue('overwriteprotocol');
}
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Avoid too many return
statements within this method. Open
return $this[$name] ?? null;
Function getId
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function getId() {
// allow clients to provide a request id
if (isset($this->server['HTTP_X_REQUEST_ID'])) {
$reqId = $this->server['HTTP_X_REQUEST_ID'];
if (\strlen($reqId) > 19
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function passesCSRFCheck
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function passesCSRFCheck() {
if ($this->csrfTokenManager === null) {
return false;
}
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"