Showing 29 of 29 total issues
Function process
has a Cognitive Complexity of 60 (exceeds 5 allowed). Consider refactoring. Open
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
{
$actualHost = $request->getServerParams()['REMOTE_ADDR'] ?? null;
if ($actualHost === null) {
// Validation is not possible.
- 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
File TrustedHostsNetworkResolver.php
has 365 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
declare(strict_types=1);
namespace Yiisoft\Yii\Web\Middleware;
Method process
has 107 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
{
$actualHost = $request->getServerParams()['REMOTE_ADDR'] ?? null;
if ($actualHost === null) {
// Validation is not possible.
Function process
has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring. Open
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
{
$newScheme = null;
foreach ($this->protocolHeaders as $header => $data) {
if (!$request->hasHeader($header)) {
- 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 getElementsByRfc7239
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
private function getElementsByRfc7239(array $forwards): array
{
$list = [];
foreach ($forwards as $forward) {
$data = HeaderValueHelper::getParameters($forward);
- 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 process
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
{
$uri = $request->getUri();
$path = $uri->getPath();
$prefix = $this->prefix;
- 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 withAddedTrustedHosts
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
public function withAddedTrustedHosts(
array $hosts,
// Defining default headers is not secure!
array $ipHeaders = [],
array $protocolHeaders = [],
- 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 prepareProtocolHeaders
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
private function prepareProtocolHeaders(array $protocolHeaders): array
{
$output = [];
foreach ($protocolHeaders as $header => $protocolAndAcceptedValues) {
$header = strtolower($header);
- 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 withAddedTrustedHosts
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function withAddedTrustedHosts(
array $hosts,
// Defining default headers is not secure!
array $ipHeaders = [],
array $protocolHeaders = [],
Function getHeadersFromGlobals
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
private function getHeadersFromGlobals(): array
{
if (function_exists('getallheaders')) {
$headers = getallheaders();
return $headers === false ? [] : $headers;
- 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 process
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
{
$uri = $request->getUri();
$path = $uri->getPath();
$prefix = $this->prefix;
Function process
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
{
if (
($this->lastModified === null && $this->etagSeed === null) ||
!\in_array($request->getMethod(), [Method::GET, Method::HEAD], true)
- 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 emit
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
public function emit(ResponseInterface $response, bool $withoutBody = false): void
{
$status = $response->getStatusCode();
$withoutBody = $withoutBody || !$this->shouldOutputBody($response);
$withoutContentLength = $withoutBody || $response->hasHeader('Transfer-Encoding');
- 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 createFromParameters
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public function createFromParameters(array $server, array $headers = [], array $cookies = [], array $get = [], array $post = [], array $files = [], $body = null): ServerRequestInterface
{
$method = $server['REQUEST_METHOD'] ?? null;
if ($method === null) {
throw new RuntimeException('Unable to determine HTTP request method.');
- 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 process
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
{
if (
($this->lastModified === null && $this->etagSeed === null) ||
!\in_array($request->getMethod(), [Method::GET, Method::HEAD], true)
Method getElementsByRfc7239
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function getElementsByRfc7239(array $forwards): array
{
$list = [];
foreach ($forwards as $forward) {
$data = HeaderValueHelper::getParameters($forward);
Method createFromParameters
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function createFromParameters(array $server, array $headers = [], array $cookies = [], array $get = [], array $post = [], array $files = [], $body = null): ServerRequestInterface
{
$method = $server['REQUEST_METHOD'] ?? null;
if ($method === null) {
throw new RuntimeException('Unable to determine HTTP request method.');
Method process
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
{
$newScheme = null;
foreach ($this->protocolHeaders as $header => $data) {
if (!$request->hasHeader($header)) {
Method emit
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function emit(ResponseInterface $response, bool $withoutBody = false): void
{
$status = $response->getStatusCode();
$withoutBody = $withoutBody || !$this->shouldOutputBody($response);
$withoutContentLength = $withoutBody || $response->hasHeader('Transfer-Encoding');
Function getUri
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
private function getUri(array $server): UriInterface
{
$uri = $this->uriFactory->createUri();
if (array_key_exists('HTTPS', $server) && $server['HTTPS'] !== '' && $server['HTTPS'] !== 'off') {
- 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"