Showing 19 of 64 total issues
Function readPoFile
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
private function readPoFile($lines)
{
// Strip comments
$lines = array_filter($lines, function ($line) {
return strpos($line, '#') !== 0;
- 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
AbstractLocale
has 21 functions (exceeds 20 allowed). Consider refactoring. Open
abstract class AbstractLocale
{
// "Source" strings, when translating numbers
const DECIMAL = '.'; // The default decimal mark
const GROUP = ','; // The digit group separator
Method readPoFile
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function readPoFile($lines)
{
// Strip comments
$lines = array_filter($lines, function ($line) {
return strpos($line, '#') !== 0;
Function httpAcceptDowngrade
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
private static function httpAcceptDowngrade($preferences)
{
foreach ($preferences as $code => $priority) {
// Three parts: "zh-hans-cn" => "zh-hans" and "zh"
if (preg_match('/^(([a-z]+)-[a-z]+)-[a-z]+$/', $code, $match) === 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"
Further reading
Method __construct
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function __construct($filename)
{
$this->translations = array();
switch (strtolower(pathinfo($filename, PATHINFO_EXTENSION))) {
Function __construct
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public function __construct($filename)
{
$this->translations = array();
switch (strtolower(pathinfo($filename, PATHINFO_EXTENSION))) {
- 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 httpAcceptLanguage
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function httpAcceptLanguage(array $server, array $available, LocaleInterface $default)
{
if (!empty($server['HTTP_ACCEPT_LANGUAGE'])) {
$http_accept_language = strtolower(str_replace(' ', '', $server['HTTP_ACCEPT_LANGUAGE']));
preg_match_all('/([a-z][a-z0-9_-]+)(?:;q=([0-9.]+))?/', $http_accept_language, $match);
Function httpAcceptLanguage
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public static function httpAcceptLanguage(array $server, array $available, LocaleInterface $default)
{
if (!empty($server['HTTP_ACCEPT_LANGUAGE'])) {
$http_accept_language = strtolower(str_replace(' ', '', $server['HTTP_ACCEPT_LANGUAGE']));
preg_match_all('/([a-z][a-z0-9_-]+)(?:;q=([0-9.]+))?/', $http_accept_language, $match);
- 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 plural
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function plural($number)
{
$number = abs($number);
if ($number === 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"
Further reading
Function number
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function number($number)
{
if ($number < 0) {
$number = -$number;
$negative = self::NEGATIVE;
- 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 4;
Avoid too many return
statements within this method. Open
return 4;
Avoid too many return
statements within this method. Open
return $default;
Avoid too many return
statements within this method. Open
return 4;
Avoid too many return
statements within this method. Open
return 5;
Function code
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function code()
{
$code = $this->language()->code() . '_' . $this->territory()->code();
$script = $this->script()->unicodeName();
- 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 plural
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function plural($number)
{
$number = abs($number);
if ($number === 1 || $number === 11) {
- 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 plural
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function plural($number)
{
$number = abs($number);
if ($number === 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"
Further reading
Function plural
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function plural($number)
{
$number = abs($number);
if ($number === 0) {
- 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"