Function recache
has a Cognitive Complexity of 113 (exceeds 5 allowed). Consider refactoring. Open
public function recache( $code ) {
if ( !$code ) {
throw new InvalidArgumentException( "Invalid language code requested" );
}
$this->recachedLangs[ $code ] = 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
File LocalisationCache.php
has 770 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
Method recache
has 189 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function recache( $code ) {
if ( !$code ) {
throw new InvalidArgumentException( "Invalid language code requested" );
}
$this->recachedLangs[ $code ] = true;
Function initLanguage
has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring. Open
private function initLanguage( $code ) {
if ( isset( $this->initialisedLangs[$code] ) ) {
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
LocalisationCache
has 30 functions (exceeds 20 allowed). Consider refactoring. Open
class LocalisationCache {
public const VERSION = 5;
/** @var ServiceOptions */
private $options;
Function loadCoreData
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
private function loadCoreData( string $code ) {
if ( !$code ) {
throw new InvalidArgumentException( "Invalid language code requested" );
}
if ( $this->coreDataLoaded[$code] ?? 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
Method initLanguage
has 65 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function initLanguage( $code ) {
if ( isset( $this->initialisedLangs[$code] ) ) {
return;
}
Function loadItem
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
private function loadItem( $code, $key ) {
if ( isset( $this->loadedItems[$code][$key] ) ) {
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
Method loadCoreData
has 55 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function loadCoreData( string $code ) {
if ( !$code ) {
throw new InvalidArgumentException( "Invalid language code requested" );
}
if ( $this->coreDataLoaded[$code] ?? false ) {
Function readPHPFile
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
protected function readPHPFile( $_fileName, $_fileType ) {
include $_fileName;
$data = [];
if ( $_fileType == 'core' ) {
- 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 mergeItem
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
private function mergeItem( $key, &$value, $fallbackValue ) {
if ( $value !== null ) {
if ( $fallbackValue !== null ) {
if ( in_array( $key, self::MERGEABLE_MAP_KEYS ) ) {
$value += $fallbackValue;
- 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 loadItem
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function loadItem( $code, $key ) {
if ( isset( $this->loadedItems[$code][$key] ) ) {
return;
}
Function loadPluralFile
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
private static function loadPluralFile( $fileName ) {
// Use file_get_contents instead of DOMDocument::load (T58439)
$xml = file_get_contents( $fileName );
if ( !$xml ) {
throw new RuntimeException( "Unable to read plurals file $fileName" );
- 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 loadSubitem
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function loadSubitem( $code, $key, $subkey ) {
if ( !in_array( $key, self::SPLIT_KEYS ) ) {
$this->loadItem( $code, $key );
return;
Function getStoreFromConf
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public static function getStoreFromConf( array $conf, $fallbackCacheDir ): LCStore {
$storeArg = [];
$storeArg['directory'] =
$conf['storeDirectory'] ?: $fallbackCacheDir;
- 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 loadSubitem
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
private function loadSubitem( $code, $key, $subkey ) {
if ( !in_array( $key, self::SPLIT_KEYS ) ) {
$this->loadItem( $code, $key );
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
Method __construct
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
ServiceOptions $options,
LCStore $store,
LoggerInterface $logger,
array $clearStoreCallbacks,
LanguageNameUtils $langNameUtils,
Function isExpired
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function isExpired( $code ) {
if ( $this->options->get( 'forceRecache' ) && !isset( $this->recachedLangs[$code] ) ) {
$this->logger->debug( __METHOD__ . "($code): forced reload" );
return 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 readJSONFile
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
private function readJSONFile( $fileName ) {
if ( !is_readable( $fileName ) ) {
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"