File Config.php
has 771 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
declare(strict_types=1);
namespace PhpMyAdmin;
Config
has 41 functions (exceeds 20 allowed). Consider refactoring. Open
class Config
{
public static self|null $instance = null;
/** @var mixed[] default configuration settings */
Function loadUserPreferences
has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring. Open
public function loadUserPreferences(ThemeManager $themeManager, bool $isMinimumCommon = false): void
{
$cacheKey = 'server_' . Current::$server;
if (Current::$server > 0 && ! $isMinimumCommon) {
// cache user preferences, use database only when needed
- 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 loadUserPreferences
has 68 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function loadUserPreferences(ThemeManager $themeManager, bool $isMinimumCommon = false): void
{
$cacheKey = 'server_' . Current::$server;
if (Current::$server > 0 && ! $isMinimumCommon) {
// cache user preferences, use database only when needed
Function selectServer
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
public function selectServer(mixed $serverParamFromRequest): int
{
$serverNumber = 0;
if (is_numeric($serverParamFromRequest)) {
$serverNumber = (int) $serverParamFromRequest;
- 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 getConnectionParams
has 56 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function getConnectionParams(Server $currentServer, ConnectionType $connectionType): Server
{
if ($connectionType !== ConnectionType::ControlUser) {
if ($currentServer->host !== '' && $currentServer->port !== '') {
return $currentServer;
Function checkClient
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
public function checkClient(): void
{
$httpUserAgent = '';
if (Core::getEnv('HTTP_USER_AGENT') !== '') {
$httpUserAgent = Core::getEnv('HTTP_USER_AGENT');
- 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 checkClient
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function checkClient(): void
{
$httpUserAgent = '';
if (Core::getEnv('HTTP_USER_AGENT') !== '') {
$httpUserAgent = Core::getEnv('HTTP_USER_AGENT');
Function setCookie
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
public function setCookie(
string $cookie,
string $value,
string|null $default = null,
int|null $validity = null,
- 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 isHttps
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public function isHttps(): bool
{
/** @var mixed $isHttps */
$isHttps = $this->get('is_https');
if (is_bool($isHttps)) {
- 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 selectServer
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function selectServer(mixed $serverParamFromRequest): int
{
$serverNumber = 0;
if (is_numeric($serverParamFromRequest)) {
$serverNumber = (int) $serverParamFromRequest;
Method setCookie
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function setCookie(
string $cookie,
string $value,
string|null $default = null,
int|null $validity = null,
Method load
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function load(string|null $source = null): bool
{
if ($source !== null) {
$this->setSource($source);
}
Method isHttps
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function isHttps(): bool
{
/** @var mixed $isHttps */
$isHttps = $this->get('is_https');
if (is_bool($isHttps)) {
Function getRootPath
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public function getRootPath(): string
{
$url = $this->get('PmaAbsoluteUri');
if (! empty($url)) {
- 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 getTempDir
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function getTempDir(string $name): string|null
{
if (isset(self::$tempDir[$name])) {
return self::$tempDir[$name];
}
- 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 load
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function load(string|null $source = null): bool
{
if ($source !== null) {
$this->setSource($source);
}
- 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 setCookie
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
string $cookie,
string $value,
string|null $default = null,
int|null $validity = null,
bool $httponly = true,
Function checkConfigSource
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function checkConfigSource(): bool
{
if ($this->getSource() === '') {
// no configuration file set at all
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"
Further reading
Function getConnectionParams
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public static function getConnectionParams(Server $currentServer, ConnectionType $connectionType): Server
{
if ($connectionType !== ConnectionType::ControlUser) {
if ($currentServer->host !== '' && $currentServer->port !== '') {
return $currentServer;
- 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 setUserValue
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function setUserValue(
string|null $cookieName,
string $cfgPath,
mixed $newCfgValue,
string|null $defaultValue = null,
- 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 true;
Avoid too many return
statements within this method. Open
return setcookie($httpCookieName, $value, $optionalParams);
Function setClientPlatform
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
private function setClientPlatform(string $userAgent): void
{
if (str_contains($userAgent, 'Win')) {
$this->set('PMA_USR_OS', 'Win');
} elseif (str_contains($userAgent, 'Mac')) {
- 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 checkGd2
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function checkGd2(): void
{
if ($this->get('GD2Available') === 'yes') {
$this->set('PMA_IS_GD2', 1);
- 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"