src/Process/Http/AccessLog.php
Function getIpAddress
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
Open
public static function getIpAddress(RequestInterface $request): string
{
if (! ($request instanceof ServerRequestInterface)) {
return "-";
}
- 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
Open
return $server['REMOTE_ADDR'];
Avoid too many return
statements within this method. Open
Open
return $server['HTTP_X_CLUSTER_CLIENT_IP'];
Avoid too many return
statements within this method. Open
Open
return $server['HTTP_FORWARDED_FOR'];
Avoid too many return
statements within this method. Open
Open
return $server['HTTP_FORWARDED'];
syntax error, unexpected 'string' (T_STRING), expecting function (T_FUNCTION) or const (T_CONST)
Open
Open
private string $format = "{Remote} {UserId} {UserName} {Timestamp} \"{Request}\" %>{Status} {RequestSize} \"{Referrer}\" \"{UserAgent}\"";
- Exclude checks
Line exceeds 120 characters; contains 136 characters Open
Open
* - {Referrer} – Referrer header, or dash if not used (In other words, did they click a URL on another site to come to your site)
- Exclude checks
Line exceeds 120 characters; contains 142 characters Open
Open
private string $format = "{Remote} {UserId} {UserName} {Timestamp} \"{Request}\" %>{Status} {RequestSize} \"{Referrer}\" \"{UserAgent}\"";
- Exclude checks
Line exceeds 120 characters; contains 129 characters Open
Open
public function __invoke(RequestInterface $request, UnitTrackerInterface $unitTracker, LoggerInterface $logger, $user = null)
- Exclude checks