Function getPluralized
has a Cognitive Complexity of 64 (exceeds 5 allowed). Consider refactoring. Open
private static function getPluralized($count)
{
//Extract language code from locale with special cases
if (0 === strcasecmp(static::getLanguage(), 'pt-BR')) {
$lang = 'pt-BR';
- 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 Language.php
has 526 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
namespace App;
/**
Method getPluralized
has 196 lines of code (exceeds 25 allowed). Consider refactoring. Open
private static function getPluralized($count)
{
//Extract language code from locale with special cases
if (0 === strcasecmp(static::getLanguage(), 'pt-BR')) {
$lang = 'pt-BR';
Function translate
has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring. Open
public static function translate(string $key, string $moduleName = '_Base', ?string $language = null, bool $encode = true, ?string $secondModuleName = null)
{
if (empty($key)) { // nothing to translate
return $key;
}
- 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
The class Language has an overall complexity of 197 which is very high. The configured complexity threshold is 50. Open
class Language
{
/**
* Default language code.
*/
- Exclude checks
Function loadLanguageFile
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
public static function loadLanguageFile($language, $moduleName = '_Base')
{
if (!isset(static::$languageContainer[$language][$moduleName])) {
if (Cache::has('LanguageFiles', $language . $moduleName)) {
static::$languageContainer[$language][$moduleName] = Cache::get('LanguageFiles', $language . $moduleName);
- 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
Language
has 25 functions (exceeds 20 allowed). Consider refactoring. Open
class Language
{
/**
* Default language code.
*/
Method translate
has 54 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function translate(string $key, string $moduleName = '_Base', ?string $language = null, bool $encode = true, ?string $secondModuleName = null)
{
if (empty($key)) { // nothing to translate
return $key;
}
Function translationModify
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public static function translationModify(string $language, string $fileName, string $type, string $label, string $translation, bool $remove = false)
{
$fileLocation = explode('__', $fileName, 2);
array_unshift($fileLocation, 'custom', 'languages', $language);
$fileDirectory = ROOT_DIRECTORY . \DIRECTORY_SEPARATOR . implode(\DIRECTORY_SEPARATOR, $fileLocation) . '.' . static::FORMAT;
- 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 translationModify
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
public static function translationModify(string $language, string $fileName, string $type, string $label, string $translation, bool $remove = false)
Method translate
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public static function translate(string $key, string $moduleName = '_Base', ?string $language = null, bool $encode = true, ?string $secondModuleName = null)
Function getAll
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public static function getAll(bool $active = true, bool $allData = false)
{
$cacheKey = $active ? 'Active' : 'All';
if (Cache::has('getAllLanguages', $cacheKey)) {
if (!$allData) {
- 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 initLocale
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public static function initLocale()
{
$original = explode(';', setlocale(LC_ALL, 0));
$defaultCharset = strtolower(\App\Config::main('default_charset'));
setlocale(
- 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 '_1';
Avoid too many return
statements within this method. Open
return '_2';
Avoid too many return
statements within this method. Open
return '_1';
Avoid too many return
statements within this method. Open
return '_0';
Avoid too many return
statements within this method. Open
return '_0';
Avoid too many return
statements within this method. Open
return \nl2br(static::$languageContainer[$language]['_Base']['php'][$key]);
Avoid too many return
statements within this method. Open
return '_1';
Avoid too many return
statements within this method. Open
return '_1';
Avoid too many return
statements within this method. Open
return '_0';
Avoid too many return
statements within this method. Open
return '_3';
Avoid too many return
statements within this method. Open
return '_3';
Avoid too many return
statements within this method. Open
return '_0';
Avoid too many return
statements within this method. Open
return '_3';
Avoid too many return
statements within this method. Open
return '';
Avoid too many return
statements within this method. Open
return '_2';
Avoid too many return
statements within this method. Open
return '_1';
Avoid too many return
statements within this method. Open
return '_1';
Avoid too many return
statements within this method. Open
return '_2';
Avoid too many return
statements within this method. Open
return '_0';
Avoid too many return
statements within this method. Open
return '_2';
Avoid too many return
statements within this method. Open
return '_0';
Avoid too many return
statements within this method. Open
return '_2';
Avoid too many return
statements within this method. Open
return '_4';
Avoid too many return
statements within this method. Open
return '_0';
Avoid too many return
statements within this method. Open
return \nl2br(Purifier::encodeHtml(static::$languageContainer[$language][$base]['php'][$key]));
Avoid too many return
statements within this method. Open
return \nl2br(static::$languageContainer[$language][$base]['php'][$key]);
Avoid too many return
statements within this method. Open
return '_1';
Avoid too many return
statements within this method. Open
return '_3';
Avoid too many return
statements within this method. Open
return '_1';
Avoid too many return
statements within this method. Open
return '_0';
Avoid too many return
statements within this method. Open
return '_1';
Avoid too many return
statements within this method. Open
return '_2';
Avoid too many return
statements within this method. Open
return '_3';
Avoid too many return
statements within this method. Open
return '_0';
Avoid too many return
statements within this method. Open
return '_0';
Avoid too many return
statements within this method. Open
return '_0';
Avoid too many return
statements within this method. Open
return '_0';
Avoid too many return
statements within this method. Open
return '_3';
Avoid too many return
statements within this method. Open
return '_0';
Avoid too many return
statements within this method. Open
return '_4';
Avoid too many return
statements within this method. Open
return static::translate($key, $moduleName, static::DEFAULT_LANG, $encode, $secondModuleName);
Avoid too many return
statements within this method. Open
return '_1';
Avoid too many return
statements within this method. Open
return '_2';
Avoid too many return
statements within this method. Open
return '_0';
Avoid too many return
statements within this method. Open
return '_1';
Avoid too many return
statements within this method. Open
return \nl2br(static::$languageContainer[$language][$secondModuleName]['php'][$key]);
Avoid too many return
statements within this method. Open
return \nl2br(Purifier::encodeHtml(static::$languageContainer[$language]['_Base']['php'][$key]));
Avoid too many return
statements within this method. Open
return '_0';
Avoid too many return
statements within this method. Open
return '_2';
Avoid too many return
statements within this method. Open
return '_2';
Avoid too many return
statements within this method. Open
return '_1';
Avoid too many return
statements within this method. Open
return '_3';
Avoid too many return
statements within this method. Open
return '_1';
Avoid too many return
statements within this method. Open
return '_2';
Avoid too many return
statements within this method. Open
return '_2';
Avoid too many return
statements within this method. Open
return \nl2br(Purifier::encodeHtml(static::$languageContainer[$language][$secondModuleName]['php'][$key]));
Avoid too many return
statements within this method. Open
return $encode ? Purifier::encodeHtml($key) : $key;
Avoid too many return
statements within this method. Open
return '_2';
Avoid too many return
statements within this method. Open
return '_2';
Avoid too many return
statements within this method. Open
return '_2';
Avoid too many return
statements within this method. Open
return '_2';
Avoid too many return
statements within this method. Open
return '_1';
Avoid too many return
statements within this method. Open
return '_1';
Avoid too many return
statements within this method. Open
return '_5';
Function translateSingleMod
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public static function translateSingleMod($key, $moduleName = '_Base', $language = false, $encode = true)
{
if (!$language) {
$language = static::getLanguage();
}
- 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
The method translate() has an NPath complexity of 27648. The configured NPath complexity threshold is 200. Open
public static function translate(string $key, string $moduleName = '_Base', ?string $language = null, bool $encode = true, ?string $secondModuleName = null)
{
if (empty($key)) { // nothing to translate
return $key;
}
- Read upRead up
- Exclude checks
NPathComplexity
Since: 0.1
The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.
Example
class Foo {
function bar() {
// lots of complicated code
}
}
Source https://phpmd.org/rules/codesize.html#npathcomplexity
The method getPluralized() has 217 lines of code. Current threshold is set to 100. Avoid really long methods. Open
private static function getPluralized($count)
{
//Extract language code from locale with special cases
if (0 === strcasecmp(static::getLanguage(), 'pt-BR')) {
$lang = 'pt-BR';
- Exclude checks
The method getPluralized() has an NPath complexity of 9360. The configured NPath complexity threshold is 200. Open
private static function getPluralized($count)
{
//Extract language code from locale with special cases
if (0 === strcasecmp(static::getLanguage(), 'pt-BR')) {
$lang = 'pt-BR';
- Read upRead up
- Exclude checks
NPathComplexity
Since: 0.1
The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.
Example
class Foo {
function bar() {
// lots of complicated code
}
}
Source https://phpmd.org/rules/codesize.html#npathcomplexity
The method translate() has a Cyclomatic Complexity of 20. The configured cyclomatic complexity threshold is 10. Open
public static function translate(string $key, string $moduleName = '_Base', ?string $language = null, bool $encode = true, ?string $secondModuleName = null)
{
if (empty($key)) { // nothing to translate
return $key;
}
- Read upRead up
- Exclude checks
CyclomaticComplexity
Since: 0.1
Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.
Example
// Cyclomatic Complexity = 11
class Foo {
1 public function example() {
2 if ($a == $b) {
3 if ($a1 == $b1) {
fiddle();
4 } elseif ($a2 == $b2) {
fiddle();
} else {
fiddle();
}
5 } elseif ($c == $d) {
6 while ($c == $d) {
fiddle();
}
7 } elseif ($e == $f) {
8 for ($n = 0; $n < $h; $n++) {
fiddle();
}
} else {
switch ($z) {
9 case 1:
fiddle();
break;
10 case 2:
fiddle();
break;
11 case 3:
fiddle();
break;
default:
fiddle();
break;
}
}
}
}
Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity
The method getPluralized() has a Cyclomatic Complexity of 103. The configured cyclomatic complexity threshold is 10. Open
private static function getPluralized($count)
{
//Extract language code from locale with special cases
if (0 === strcasecmp(static::getLanguage(), 'pt-BR')) {
$lang = 'pt-BR';
- Read upRead up
- Exclude checks
CyclomaticComplexity
Since: 0.1
Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.
Example
// Cyclomatic Complexity = 11
class Foo {
1 public function example() {
2 if ($a == $b) {
3 if ($a1 == $b1) {
fiddle();
4 } elseif ($a2 == $b2) {
fiddle();
} else {
fiddle();
}
5 } elseif ($c == $d) {
6 while ($c == $d) {
fiddle();
}
7 } elseif ($e == $f) {
8 for ($n = 0; $n < $h; $n++) {
fiddle();
}
} else {
switch ($z) {
9 case 1:
fiddle();
break;
10 case 2:
fiddle();
break;
11 case 3:
fiddle();
break;
default:
fiddle();
break;
}
}
}
}
Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity
Reduce the number of returns of this function 4, down to the maximum allowed 3. Open
public static function translateSingleMod($key, $moduleName = '_Base', $language = false, $encode = true)
- Read upRead up
- Exclude checks
Having too many return statements in a function increases the function's essential complexity because the flow of execution is broken each time a return statement is encountered. This makes it harder to read and understand the logic of the function.
Noncompliant Code Example
With the default threshold of 3:
function myFunction(){ // Noncompliant as there are 4 return statements if (condition1) { return true; } else { if (condition2) { return false; } else { return true; } } return false; }
Class "Language" has 25 methods, which is greater than 20 authorized. Split it into smaller classes. Open
class Language
- Read upRead up
- Exclude checks
A class that grows too much tends to aggregate too many responsibilities and inevitably becomes harder to understand and therefore to maintain. Above a specific threshold, it is strongly advised to refactor the class into smaller ones which focus on well defined topics.
Reduce the number of returns of this function 4, down to the maximum allowed 3. Open
public static function getAll(bool $active = true, bool $allData = false)
- Read upRead up
- Exclude checks
Having too many return statements in a function increases the function's essential complexity because the flow of execution is broken each time a return statement is encountered. This makes it harder to read and understand the logic of the function.
Noncompliant Code Example
With the default threshold of 3:
function myFunction(){ // Noncompliant as there are 4 return statements if (condition1) { return true; } else { if (condition2) { return false; } else { return true; } } return false; }
Refactor this function to reduce its Cognitive Complexity from 28 to the 15 allowed. Open
public static function translate(string $key, string $moduleName = '_Base', ?string $language = null, bool $encode = true, ?string $secondModuleName = null)
- Read upRead up
- Exclude checks
Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.
See
Reduce the number of returns of this function 12, down to the maximum allowed 3. Open
public static function translate(string $key, string $moduleName = '_Base', ?string $language = null, bool $encode = true, ?string $secondModuleName = null)
- Read upRead up
- Exclude checks
Having too many return statements in a function increases the function's essential complexity because the flow of execution is broken each time a return statement is encountered. This makes it harder to read and understand the logic of the function.
Noncompliant Code Example
With the default threshold of 3:
function myFunction(){ // Noncompliant as there are 4 return statements if (condition1) { return true; } else { if (condition2) { return false; } else { return true; } } return false; }
Refactor this function to reduce its Cognitive Complexity from 23 to the 15 allowed. Open
public static function loadLanguageFile($language, $moduleName = '_Base')
- Read upRead up
- Exclude checks
Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.
See
This function "getPluralized" has 216 lines, which is greater than the 150 lines authorized. Split it into smaller functions. Open
private static function getPluralized($count)
- Read upRead up
- Exclude checks
A function that grows too large tends to aggregate too many responsibilities.
Such functions inevitably become harder to understand and therefore harder to maintain.
Above a specific threshold, it is strongly advised to refactor into smaller functions which focus on well-defined tasks.
Those smaller functions will not only be easier to understand, but also probably easier to test.
Reduce the number of returns of this function 60, down to the maximum allowed 3. Open
private static function getPluralized($count)
- Read upRead up
- Exclude checks
Having too many return statements in a function increases the function's essential complexity because the flow of execution is broken each time a return statement is encountered. This makes it harder to read and understand the logic of the function.
Noncompliant Code Example
With the default threshold of 3:
function myFunction(){ // Noncompliant as there are 4 return statements if (condition1) { return true; } else { if (condition2) { return false; } else { return true; } } return false; }
Refactor this function to reduce its Cognitive Complexity from 121 to the 15 allowed. Open
private static function getPluralized($count)
- Read upRead up
- Exclude checks
Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.
See
The class Language has a coupling between objects value of 14. Consider to reduce the number of dependencies under 13. Open
class Language
{
/**
* Default language code.
*/
- Read upRead up
- Exclude checks
CouplingBetweenObjects
Since: 1.1.0
A class with too many dependencies has negative impacts on several quality aspects of a class. This includes quality criteria like stability, maintainability and understandability
Example
class Foo {
/**
* @var \foo\bar\X
*/
private $x = null;
/**
* @var \foo\bar\Y
*/
private $y = null;
/**
* @var \foo\bar\Z
*/
private $z = null;
public function setFoo(\Foo $foo) {}
public function setBar(\Bar $bar) {}
public function setBaz(\Baz $baz) {}
/**
* @return \SplObjectStorage
* @throws \OutOfRangeException
* @throws \InvalidArgumentException
* @throws \ErrorException
*/
public function process(\Iterator $it) {}
// ...
}
Source https://phpmd.org/rules/design.html#couplingbetweenobjects
The method translateEncodeHtml has a boolean flag argument $currentLanguage, which is a certain sign of a Single Responsibility Principle violation. Open
public static function translateEncodeHtml($key, $moduleName = '_Base', $currentLanguage = false)
- Read upRead up
- Exclude checks
BooleanArgumentFlag
Since: 1.4.0
A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.
Example
class Foo {
public function bar($flag = true) {
}
}
Source https://phpmd.org/rules/cleancode.html#booleanargumentflag
The method getAll has a boolean flag argument $allData, which is a certain sign of a Single Responsibility Principle violation. Open
public static function getAll(bool $active = true, bool $allData = false)
- Read upRead up
- Exclude checks
BooleanArgumentFlag
Since: 1.4.0
A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.
Example
class Foo {
public function bar($flag = true) {
}
}
Source https://phpmd.org/rules/cleancode.html#booleanargumentflag
The method translationModify has a boolean flag argument $remove, which is a certain sign of a Single Responsibility Principle violation. Open
public static function translationModify(string $language, string $fileName, string $type, string $label, string $translation, bool $remove = false)
- Read upRead up
- Exclude checks
BooleanArgumentFlag
Since: 1.4.0
A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.
Example
class Foo {
public function bar($flag = true) {
}
}
Source https://phpmd.org/rules/cleancode.html#booleanargumentflag
The method translate has a boolean flag argument $encode, which is a certain sign of a Single Responsibility Principle violation. Open
public static function translate(string $key, string $moduleName = '_Base', ?string $language = null, bool $encode = true, ?string $secondModuleName = null)
- Read upRead up
- Exclude checks
BooleanArgumentFlag
Since: 1.4.0
A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.
Example
class Foo {
public function bar($flag = true) {
}
}
Source https://phpmd.org/rules/cleancode.html#booleanargumentflag
The method getAll has a boolean flag argument $active, which is a certain sign of a Single Responsibility Principle violation. Open
public static function getAll(bool $active = true, bool $allData = false)
- Read upRead up
- Exclude checks
BooleanArgumentFlag
Since: 1.4.0
A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.
Example
class Foo {
public function bar($flag = true) {
}
}
Source https://phpmd.org/rules/cleancode.html#booleanargumentflag
The method translateSingleMod has a boolean flag argument $language, which is a certain sign of a Single Responsibility Principle violation. Open
public static function translateSingleMod($key, $moduleName = '_Base', $language = false, $encode = true)
- Read upRead up
- Exclude checks
BooleanArgumentFlag
Since: 1.4.0
A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.
Example
class Foo {
public function bar($flag = true) {
}
}
Source https://phpmd.org/rules/cleancode.html#booleanargumentflag
The method translateSingleMod has a boolean flag argument $encode, which is a certain sign of a Single Responsibility Principle violation. Open
public static function translateSingleMod($key, $moduleName = '_Base', $language = false, $encode = true)
- Read upRead up
- Exclude checks
BooleanArgumentFlag
Since: 1.4.0
A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.
Example
class Foo {
public function bar($flag = true) {
}
}
Source https://phpmd.org/rules/cleancode.html#booleanargumentflag
Avoid using static access to class 'App\Purifier' in method 'translateSingleMod'. Open
return Purifier::encodeHtml(static::$languageContainer[$language][$moduleName]['php'][$key]);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class 'App\Purifier' in method 'translateSingleMod'. Open
return $encode ? Purifier::encodeHtml($key) : $key;
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class 'App\Cache' in method 'getAll'. Open
return Cache::get('getAllLanguages', $cacheKey);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class 'App\Json' in method 'translationModify'. Open
if (false === Json::save($fileDirectory, $translations)) {
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class 'App\Purifier' in method 'translate'. Open
return \nl2br(Purifier::encodeHtml(static::$languageContainer[$language][$base]['php'][$key]));
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Config' in method 'translate'. Open
if (\App\Config::performance('recursiveTranslate') && static::DEFAULT_LANG !== $language) {
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class 'App\Cache' in method 'getAll'. Open
if (Cache::has('getAllLanguages', $cacheKey)) {
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class 'App\Cache' in method 'getAll'. Open
return Cache::get('getAllLanguages', $cacheKey);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Purifier' in method 'translateEncodeHtml'. Open
return \App\Purifier::encodeHtml(static::translate($key, $moduleName, $currentLanguage));
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
The method loadLanguageFile uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
static::$languageContainer[$language][$moduleName] = [];
$file = \DIRECTORY_SEPARATOR . 'languages' . \DIRECTORY_SEPARATOR . $language . \DIRECTORY_SEPARATOR . $moduleName . '.' . static::FORMAT;
$langFile = ROOT_DIRECTORY . $file;
if (file_exists($langFile)) {
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
Avoid using static access to class 'App\Cache' in method 'getAll'. Open
Cache::save('getLangInfo', $row['prefix'], $row);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\Locale' in method 'initLocale'. Open
\Locale::acceptFromHttp(\App\Config::main('default_language')) . '.' . $defaultCharset,
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Session' in method 'getLanguage'. Open
$language = \App\Session::get('language');
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid assigning values to variables in if clauses and the like (line '235', column '9'). Open
public static function getTranslateHelpInfo(\Vtiger_Field_Model $fieldModel, string $view): string
{
$translate = '';
if (\in_array($view, explode(',', $fieldModel->get('helpinfo')))) {
$label = $fieldModel->getFieldLabel();
- Read upRead up
- Exclude checks
IfStatementAssignment
Since: 2.7.0
Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.
Example
class Foo
{
public function bar($flag)
{
if ($foo = 'bar') { // possible typo
// ...
}
if ($baz = 0) { // always false
// ...
}
}
}
Source http://phpmd.org/rules/cleancode.html#ifstatementassignment
Avoid using static access to class 'App\Cache' in method 'getAll'. Open
return array_column(Cache::get('getAllLanguages', $cacheKey), 'name', 'prefix');
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class 'App\Json' in method 'loadLanguageFile'. Open
static::$languageContainer[$language][$moduleName] = Json::decode(file_get_contents($langFile), true) ?? [];
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class 'App\Cache' in method 'getAll'. Open
Cache::save('getAllLanguages', 'All', $all);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class 'App\Cache' in method 'getLangInfo'. Open
return Cache::get('getLangInfo', $prefix);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Config' in method 'initLocale'. Open
$defaultCharset = strtolower(\App\Config::main('default_charset'));
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Config' in method 'initLocale'. Open
\Locale::acceptFromHttp(\App\Config::main('default_language')) . '.' . $defaultCharset,
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\Locale' in method 'initLocale'. Open
\Locale::acceptFromHttp(self::DEFAULT_LANG) . ".$defaultCharset",
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
The method getPluralized uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$lang = static::getShortLanguageName();
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
Avoid using static access to class '\Locale' in method 'getLanguageRegion'. Open
}
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class 'App\Log' in method 'translate'. Open
Log::warning('Invalid module name - module: ' . var_export($moduleName, true));
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class 'App\Cache' in method 'getAll'. Open
return array_column(Cache::get('getAllLanguages', $cacheKey), 'name', 'prefix');
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class 'App\Cache' in method 'getLangInfo'. Open
if (Cache::has('getLangInfo', $prefix)) {
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class 'App\Cache' in method 'getLangInfo'. Open
return Cache::save('getLangInfo', $prefix, (new Db\Query())->from('vtiger_language')->where(['prefix' => $prefix])->one());
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
The method translationModify uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$loc = '';
array_pop($fileLocation);
foreach ($fileLocation as $name) {
$loc .= \DIRECTORY_SEPARATOR . $name;
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
Avoid using static access to class '\Locale' in method 'initLocale'. Open
\Locale::acceptFromHttp(self::getLanguage()) . '.' . $defaultCharset,
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class 'App\Utils' in method 'getDisplayName'. Open
return Utils::mbUcfirst(locale_get_region($prefix) === strtoupper(locale_get_primary_language($prefix)) ? locale_get_display_language($prefix, $prefix) : locale_get_display_name($prefix, $prefix));
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
The method getLanguage uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$language = User::getCurrentUserModel()->getDetail('language');
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
Avoid using static access to class '\App\Config' in method 'translateSingleMod'. Open
if (\App\Config::performance('recursiveTranslate') && static::DEFAULT_LANG !== $language) {
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\Locale' in method 'getShortLanguageName'. Open
return static::$shortLanguage = (empty($match[0])) ? \Locale::getPrimaryLanguage(self::DEFAULT_LANG) : $match[0];
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class 'App\Json' in method 'loadLanguageFile'. Open
$translation = Json::decode(file_get_contents($langCustomFile), true) ?? [];
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class 'App\Module' in method 'translate'. Open
$moduleName = Module::getModuleName($moduleName);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
The method translate uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$moduleName = str_replace([':', '.'], [\DIRECTORY_SEPARATOR, \DIRECTORY_SEPARATOR], $moduleName);
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
Avoid using static access to class 'App\Purifier' in method 'translate'. Open
return $encode ? Purifier::encodeHtml($key) : $key;
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Log' in method 'loadLanguageFile'. Open
\App\Log::info("Language file does not exist, module: $moduleName ,language: $language");
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\Locale' in method 'initLocale'. Open
\Locale::acceptFromHttp(self::DEFAULT_LANG) . '.utf8'
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class 'App\Cache' in method 'loadLanguageFile'. Open
static::$languageContainer[$language][$moduleName] = Cache::get('LanguageFiles', $language . $moduleName);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
The method initLocale uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$category = 'LC_ALL';
$locale = $localeSetting;
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
Avoid using static access to class '\App\Config' in method 'getLanguage'. Open
return static::$language = empty($language) ? \App\Config::main('default_language') : $language;
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class 'App\Purifier' in method 'translate'. Open
return \nl2br(Purifier::encodeHtml(static::$languageContainer[$language][$secondModuleName]['php'][$key]));
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class 'App\Cache' in method 'loadLanguageFile'. Open
if (Cache::has('LanguageFiles', $language . $moduleName)) {
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class 'App\Json' in method 'translationModify'. Open
$translations = Json::decode(file_get_contents($fileDirectory), true);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class 'App\Cache' in method 'translationModify'. Open
Cache::delete('LanguageFiles', $language . str_replace('__', \DIRECTORY_SEPARATOR, $fileName));
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Session' in method 'getLanguage'. Open
if (!empty(\App\Session::get('language'))) {
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class 'App\Purifier' in method 'translate'. Open
return \nl2br(Purifier::encodeHtml(static::$languageContainer[$language]['_Base']['php'][$key]));
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Log' in method 'translate'. Open
\App\Log::info("Cannot translate this: '$key' for module '$moduleName', lang: $language");
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class 'App\Cache' in method 'loadLanguageFile'. Open
Cache::save('LanguageFiles', $language . $moduleName, static::$languageContainer[$language][$moduleName], Cache::LONG);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class 'App\Cache' in method 'getAll'. Open
Cache::save('getAllLanguages', 'Active', $actives);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid assigning values to variables in if clauses and the like (line '237', column '15'). Open
public static function getTranslateHelpInfo(\Vtiger_Field_Model $fieldModel, string $view): string
{
$translate = '';
if (\in_array($view, explode(',', $fieldModel->get('helpinfo')))) {
$label = $fieldModel->getFieldLabel();
- Read upRead up
- Exclude checks
IfStatementAssignment
Since: 2.7.0
Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.
Example
class Foo
{
public function bar($flag)
{
if ($foo = 'bar') { // possible typo
// ...
}
if ($baz = 0) { // always false
// ...
}
}
}
Source http://phpmd.org/rules/cleancode.html#ifstatementassignment
The method translatePluralized uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$postfix = static::getPluralized((int) $count);
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
Avoid using static access to class 'App\Purifier' in method 'translate'. Open
return \nl2br(Purifier::encodeHtml(static::$languageContainer[$language][$moduleName]['php'][$key]));
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Define a constant instead of duplicating this literal "getAllLanguages" 7 times. Open
if (Cache::has('getAllLanguages', $cacheKey)) {
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "language" 3 times. Open
if (!empty(\App\Session::get('language'))) {
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "Settings" 4 times. Open
if (0 === strpos($moduleName, 'Settings')) {
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "_Base" 12 times. Open
public static function translate(string $key, string $moduleName = '_Base', ?string $language = null, bool $encode = true, ?string $secondModuleName = null)
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "LanguageFiles" 4 times. Open
if (Cache::has('LanguageFiles', $language . $moduleName)) {
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "getLangInfo" 4 times. Open
Cache::save('getLangInfo', $row['prefix'], $row);
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "prefix" 6 times. Open
return array_column(Cache::get('getAllLanguages', $cacheKey), 'name', 'prefix');
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "pt-BR" 3 times. Open
if (0 === strcasecmp(static::getLanguage(), 'pt-BR')) {
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Call to method warning
from undeclared class \App\Log
Open
Log::warning('Invalid module name - module: ' . var_export($moduleName, true));
- Exclude checks
Call to deprecated function \Vtiger_Field_Model::getFieldLabel()
defined at /code/modules/Vtiger/models/Field.php:215
Open
$label = $fieldModel->getFieldLabel();
- Exclude checks
Argument 3 (language)
is false
but \App\Language::translate()
takes null|string
defined at /code/app/Language.php:161
Open
return \App\Purifier::encodeHtml(static::translate($key, $moduleName, $currentLanguage));
- Exclude checks
Doc-block of $secondModuleName
in translate
is phpdoc param type string
which is not a permitted replacement of the nullable param type ?string
declared in the signature ('?T' should be documented as 'T|null' or '?T') Open
* @param string $secondModuleName - Additional module name to be translated when not in $moduleName
- Exclude checks
Argument 2 (objectDecodeType)
is true
but \App\Json::decode()
takes int
defined at /code/app/Json.php:37
Open
$translation = Json::decode(file_get_contents($langCustomFile), true) ?? [];
- Exclude checks
Argument 1 (tabId)
is string
but \App\Module::getModuleName()
takes int
defined at /code/app/Module.php:129
Open
$moduleName = Module::getModuleName($moduleName);
- Exclude checks
Argument 2 (objectDecodeType)
is true
but \App\Json::decode()
takes int
defined at /code/app/Json.php:37
Open
static::$languageContainer[$language][$moduleName] = Json::decode(file_get_contents($langFile), true) ?? [];
- Exclude checks
Call to method info
from undeclared class \App\Log
Open
\App\Log::info("Language file does not exist, module: $moduleName ,language: $language");
- Exclude checks
Method \App\Language::clearTemporaryLanguage
is declared to return string
but has no return value Open
public static function clearTemporaryLanguage()
- Exclude checks
Assigning false
to property but \App\Language::$temporaryLanguage
is string
Open
static::$temporaryLanguage = false;
- Exclude checks
Call to undeclared method \App\Db\Query::from
Open
return Cache::save('getLangInfo', $prefix, (new Db\Query())->from('vtiger_language')->where(['prefix' => $prefix])->one());
- Exclude checks
Argument 2 (locale)
is 0
but \setlocale()
takes ?array
Open
$original = explode(';', setlocale(LC_ALL, 0));
- Exclude checks
Call to method getCurrentUserModel
from undeclared class \App\User
(Did you mean class \Tests\App\User) Open
$language = User::getCurrentUserModel()->getDetail('language');
- Exclude checks
Call to method info
from undeclared class \App\Log
Open
\App\Log::info("Cannot translate this: '$key' for module '$moduleName', lang: $language");
- Exclude checks
Call to undeclared method \App\Db\Query::from
Open
$dataReader = (new Db\Query())->from('vtiger_language')->createCommand()->query();
- Exclude checks
Returning type bool
but getLangInfo()
is declared to return array
Open
return Cache::save('getLangInfo', $prefix, (new Db\Query())->from('vtiger_language')->where(['prefix' => $prefix])->one());
- Exclude checks
Argument 2 (objectDecodeType)
is true
but \App\Json::decode()
takes int
defined at /code/app/Json.php:37
Open
$translations = Json::decode(file_get_contents($fileDirectory), true);
- Exclude checks
This case's code block is the same as the block for the case on line 478. Open
case 'me':
$i = $count % 10;
$j = $count % 100;
if (1 === $i && 11 !== $j) {
return '_0';
- Read upRead up
- Exclude checks
Having two cases
in a switch
statement or two branches in an if
chain with the same implementation is at
best duplicate code, and at worst a coding error. If the same logic is truly needed for both instances, then in an if
chain they should
be combined, or for a switch
, one should fall through to the other.
Noncompliant Code Example
switch ($i) { case 1: doSomething(); break; case 2: doSomethingDifferent(); break; case 3: // Noncompliant; duplicates case 1's implementation doSomething(); break; default: doTheRest(); } if ($a >= 0 && $a < 10) { doTheThing(); else if ($a >= 10 && $a < 20) { doTheOtherThing(); } else if ($a >= 20 && $a < 50) { doTheThing(); // Noncompliant; duplicates first condition } else { doTheRest(); } if ($b == 0) { doOneMoreThing(); } else { doOneMoreThing(); // Noncompliant; duplicates then-branch } var b = a ? 12 > 4 : 4; // Noncompliant; always results in the same value
Compliant Solution
switch ($i) { case 1: case 3: doSomething(); break; case 2: doSomethingDifferent(); break; default: doTheRest(); } if (($a >= 0 && $a < 10) || ($a >= 20 && $a < 50)) { doTheThing(); else if ($a >= 10 && $a < 20) { doTheOtherThing(); } else { doTheRest(); } doOneMoreThing(); b = 4;
or
switch ($i) { case 1: doSomething(); break; case 2: doSomethingDifferent(); break; case 3: doThirdThing(); break; default: doTheRest(); } if ($a >= 0 && $a < 10) { doTheThing(); else if ($a >= 10 && $a < 20) { doTheOtherThing(); } else if ($a >= 20 && $a < 50) { doTheThirdThing(); } else { doTheRest(); } if ($b == 0) { doOneMoreThing(); } else { doTheRest(); } int b = a ? 12 > 4 : 8;
Exceptions
Blocks in an if
chain that contain a single line of code are ignored, as are blocks in a switch
statement that contain a
single line of code with or without a following break
.
This case's code block is the same as the block for the case on line 499. Open
case 'pl':
$i = $count % 10;
$j = $count % 100;
if (1 === $count) {
return '_0';
- Read upRead up
- Exclude checks
Having two cases
in a switch
statement or two branches in an if
chain with the same implementation is at
best duplicate code, and at worst a coding error. If the same logic is truly needed for both instances, then in an if
chain they should
be combined, or for a switch
, one should fall through to the other.
Noncompliant Code Example
switch ($i) { case 1: doSomething(); break; case 2: doSomethingDifferent(); break; case 3: // Noncompliant; duplicates case 1's implementation doSomething(); break; default: doTheRest(); } if ($a >= 0 && $a < 10) { doTheThing(); else if ($a >= 10 && $a < 20) { doTheOtherThing(); } else if ($a >= 20 && $a < 50) { doTheThing(); // Noncompliant; duplicates first condition } else { doTheRest(); } if ($b == 0) { doOneMoreThing(); } else { doOneMoreThing(); // Noncompliant; duplicates then-branch } var b = a ? 12 > 4 : 4; // Noncompliant; always results in the same value
Compliant Solution
switch ($i) { case 1: case 3: doSomething(); break; case 2: doSomethingDifferent(); break; default: doTheRest(); } if (($a >= 0 && $a < 10) || ($a >= 20 && $a < 50)) { doTheThing(); else if ($a >= 10 && $a < 20) { doTheOtherThing(); } else { doTheRest(); } doOneMoreThing(); b = 4;
or
switch ($i) { case 1: doSomething(); break; case 2: doSomethingDifferent(); break; case 3: doThirdThing(); break; default: doTheRest(); } if ($a >= 0 && $a < 10) { doTheThing(); else if ($a >= 10 && $a < 20) { doTheOtherThing(); } else if ($a >= 20 && $a < 50) { doTheThirdThing(); } else { doTheRest(); } if ($b == 0) { doOneMoreThing(); } else { doTheRest(); } int b = a ? 12 > 4 : 8;
Exceptions
Blocks in an if
chain that contain a single line of code are ignored, as are blocks in a switch
statement that contain a
single line of code with or without a following break
.
This branch's code block is the same as the block for the branch on line 235. Open
} elseif (($translated = self::translateSingleMod($label, 'Other:HelpInfo')) !== $label) {
$translate = $translated;
}
- Read upRead up
- Exclude checks
Having two cases
in a switch
statement or two branches in an if
chain with the same implementation is at
best duplicate code, and at worst a coding error. If the same logic is truly needed for both instances, then in an if
chain they should
be combined, or for a switch
, one should fall through to the other.
Noncompliant Code Example
switch ($i) { case 1: doSomething(); break; case 2: doSomethingDifferent(); break; case 3: // Noncompliant; duplicates case 1's implementation doSomething(); break; default: doTheRest(); } if ($a >= 0 && $a < 10) { doTheThing(); else if ($a >= 10 && $a < 20) { doTheOtherThing(); } else if ($a >= 20 && $a < 50) { doTheThing(); // Noncompliant; duplicates first condition } else { doTheRest(); } if ($b == 0) { doOneMoreThing(); } else { doOneMoreThing(); // Noncompliant; duplicates then-branch } var b = a ? 12 > 4 : 4; // Noncompliant; always results in the same value
Compliant Solution
switch ($i) { case 1: case 3: doSomething(); break; case 2: doSomethingDifferent(); break; default: doTheRest(); } if (($a >= 0 && $a < 10) || ($a >= 20 && $a < 50)) { doTheThing(); else if ($a >= 10 && $a < 20) { doTheOtherThing(); } else { doTheRest(); } doOneMoreThing(); b = 4;
or
switch ($i) { case 1: doSomething(); break; case 2: doSomethingDifferent(); break; case 3: doThirdThing(); break; default: doTheRest(); } if ($a >= 0 && $a < 10) { doTheThing(); else if ($a >= 10 && $a < 20) { doTheOtherThing(); } else if ($a >= 20 && $a < 50) { doTheThirdThing(); } else { doTheRest(); } if ($b == 0) { doOneMoreThing(); } else { doTheRest(); } int b = a ? 12 > 4 : 8;
Exceptions
Blocks in an if
chain that contain a single line of code are ignored, as are blocks in a switch
statement that contain a
single line of code with or without a following break
.
Similar blocks of code found in 3 locations. Consider refactoring. Open
if (isset(static::$languageContainer[$language][$base]['php'][$key])) {
if ($encode) {
return \nl2br(Purifier::encodeHtml(static::$languageContainer[$language][$base]['php'][$key]));
}
return \nl2br(static::$languageContainer[$language][$base]['php'][$key]);
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 96.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 3 locations. Consider refactoring. Open
if (isset(static::$languageContainer[$language][$moduleName]['php'][$key])) {
if ($encode) {
return \nl2br(Purifier::encodeHtml(static::$languageContainer[$language][$moduleName]['php'][$key]));
}
return \nl2br(static::$languageContainer[$language][$moduleName]['php'][$key]);
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 96.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 3 locations. Consider refactoring. Open
if (isset(static::$languageContainer[$language][$secondModuleName]['php'][$key])) {
if ($encode) {
return \nl2br(Purifier::encodeHtml(static::$languageContainer[$language][$secondModuleName]['php'][$key]));
}
return \nl2br(static::$languageContainer[$language][$secondModuleName]['php'][$key]);
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 96.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Avoid variables with short names like $j. Configured minimum length is 3. Open
$j = $count % 100;
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
Avoid variables with short names like $i. Configured minimum length is 3. Open
$i = $count % 10;
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (static::$language) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
private static $pluralizeCache = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Set temporary language.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @var array
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return static::$language;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Clear temporary language.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Language files format.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Default language code.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
const FORMAT = 'json';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (static::$temporaryLanguage) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
static::$temporaryLanguage = $language;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $language
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Custom language directory.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
private static $temporaryLanguage = '';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Short current language.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return static::$language = empty($language) ? \App\Config::main('default_language') : $language;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
const LANG_TYPE = ['php', 'js'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$language = User::getCurrentUserModel()->getDetail('language');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Contains module language translations.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return string -
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @var array
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!empty(\App\Session::get('language'))) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$language = \App\Session::get('language');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} else {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @var string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
private static $language = '';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** @var string Temporary language. */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @var bool|string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @see https://en.wikipedia.org/wiki/IETF_language_tag
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public const DEFAULT_LANG = 'en-US';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static $customDirectory = 'custom';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Pluralize cache.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
protected static $languageContainer;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Function that returns current language.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Allowed types of language variables.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
private static $shortLanguage = false;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return str_replace('-', $separator, static::getLanguage());
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** @var string Current language. */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function getLanguage()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function getLanguageTag($separator = '_')
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function setTemporaryLanguage(string $language)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return static::$temporaryLanguage;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Get IETF language tag.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param mixed $separator
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function getShortLanguageName()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Functions that gets translated string.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (isset(static::$languageContainer[$language][$base]['php'][$key])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return \nl2br(static::$languageContainer[$language]['_Base']['php'][$key]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function translateArgs($key, $moduleName = '_Base')
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string|null $lang
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Line exceeds 120 characters; contains 121 characters Open
$secondModuleName = str_replace([':', '.'], [\DIRECTORY_SEPARATOR, \DIRECTORY_SEPARATOR], $secondModuleName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($encode) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $encode ? Purifier::encodeHtml($key) : $key;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$translate = '';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} elseif (($translated = self::translateSingleMod($label, 'Other:HelpInfo')) !== $label) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $translate;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param mixed $currentLanguage
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Log::warning('Invalid module name - module: ' . var_export($moduleName, true));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$moduleName = Module::getModuleName($moduleName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return \nl2br(Purifier::encodeHtml(static::$languageContainer[$language][$secondModuleName]['php'][$key]));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!$lang) {
- Exclude checks
Line exceeds 120 characters; contains 160 characters Open
public static function translate(string $key, string $moduleName = '_Base', ?string $language = null, bool $encode = true, ?string $secondModuleName = null)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$moduleName = str_replace([':', '.'], [\DIRECTORY_SEPARATOR, \DIRECTORY_SEPARATOR], $moduleName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (isset(static::$languageContainer[$language][$secondModuleName]['php'][$key])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (0 === strpos($moduleName, 'Settings')) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Function that returns current language short name.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string|null $language - language of translation
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $view
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (static::$shortLanguage) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return static::$shortLanguage = (empty($match[0])) ? \Locale::getPrimaryLanguage(self::DEFAULT_LANG) : $match[0];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$lang = static::getLanguage();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return \Locale::parseLocale($lang)['region'] ?? substr($lang, -2);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param bool $encode - When no translation was found do encode the output
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return string - translated string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$language = static::getLanguage();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return \nl2br(static::$languageContainer[$language][$base]['php'][$key]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (isset(static::$languageContainer[$language]['_Base']['php'][$key])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (empty($key)) { // nothing to translate
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$secondModuleName = str_replace([':', '.'], [\DIRECTORY_SEPARATOR, \DIRECTORY_SEPARATOR], $secondModuleName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $key - string which need to be translated
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
static::$temporaryLanguage = false;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Function that returns region for language prefix.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} else {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return \nl2br(Purifier::encodeHtml(static::$languageContainer[$language][$moduleName]['php'][$key]));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return \nl2br(static::$languageContainer[$language][$secondModuleName]['php'][$key]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
// Lookup for the translation in base module, in case of sub modules, before ending up with common strings
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$translate = $translated;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $moduleName - module scope in which the translation need to be check
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
static::loadLanguageFile($language, $moduleName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($encode) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return static::translate($key, $moduleName, static::DEFAULT_LANG, $encode, $secondModuleName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (\in_array($view, explode(',', $fieldModel->get('helpinfo')))) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (($translated = self::translateSingleMod($key, 'Other:HelpInfo')) !== $key) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$translate = $translated;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return \App\Purifier::encodeHtml(static::translate($key, $moduleName, $currentLanguage));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function getLanguageRegion(?string $lang = null): string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $key;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$base = 'Settings' . \DIRECTORY_SEPARATOR . '_Base';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Log::info("Cannot translate this: '$key' for module '$moduleName', lang: $language");
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $key - string which need to be translated
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($encode) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return \nl2br(Purifier::encodeHtml(static::$languageContainer[$language][$base]['php'][$key]));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Functions get translate help info.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Line exceeds 120 characters; contains 121 characters Open
return static::$shortLanguage = (empty($match[0])) ? \Locale::getPrimaryLanguage(self::DEFAULT_LANG) : $match[0];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return \nl2br(static::$languageContainer[$language][$moduleName]['php'][$key]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Functions that gets translated string by $args.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return static::$shortLanguage;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
preg_match('/^[a-z]+/i', static::getLanguage(), $match);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (is_numeric($moduleName)) { // ok, we have a tab id, lets turn it into name
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (\App\Config::performance('recursiveTranslate') && static::DEFAULT_LANG !== $language) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$key = "{$fieldModel->getModuleName()}|$label";
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $moduleName - module scope in which the translation need to be check
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function clearTemporaryLanguage()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $key;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (isset(static::$languageContainer[$language][$moduleName]['php'][$key])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
static::loadLanguageFile($language);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return \nl2br(Purifier::encodeHtml(static::$languageContainer[$language]['_Base']['php'][$key]));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Functions that gets translated string with encoding html.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return string - translated string with encoding html
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return string - translated string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $moduleName - module scope in which the translation need to be check
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!$language || ($language && 5 !== \strlen($language))) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
static::loadLanguageFile($language, $secondModuleName);
- Exclude checks
Line exceeds 120 characters; contains 127 characters Open
return \nl2br(Purifier::encodeHtml(static::$languageContainer[$language][$secondModuleName]['php'][$key]));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
static::loadLanguageFile($language, $base);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param \Vtiger_Field_Model $fieldModel
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function getTranslateHelpInfo(\Vtiger_Field_Model $fieldModel, string $view): string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function translateEncodeHtml($key, $moduleName = '_Base', $currentLanguage = false)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $key - string which need to be translated
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $secondModuleName - Additional module name to be translated when not in $moduleName
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function translate(string $key, string $moduleName = '_Base', ?string $language = null, bool $encode = true, ?string $secondModuleName = null)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (\is_array($moduleName)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($secondModuleName) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($encode) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$label = $fieldModel->getFieldLabel();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$formattedString = static::translate($key, $moduleName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $moduleName Module scope in which the translation need to be check
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $moduleName
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$return = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$postfix = static::getPluralized((int) $count);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Translation function based on only one file.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
static::loadLanguageFile($language, $moduleName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$file = \DIRECTORY_SEPARATOR . 'languages' . \DIRECTORY_SEPARATOR . $language . \DIRECTORY_SEPARATOR . $moduleName . '.' . static::FORMAT;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $language
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @see https://www.i18next.com/plurals.html
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param bool|string $language
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (\App\Config::performance('recursiveTranslate') && static::DEFAULT_LANG !== $language) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $language
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $formattedString;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $moduleName
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (isset(static::$languageContainer[$language][$moduleName]['php'][$key])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Load language file.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!isset(static::$languageContainer[$language][$moduleName])) {
- Exclude checks
Line exceeds 120 characters; contains 154 characters Open
$file = \DIRECTORY_SEPARATOR . 'languages' . \DIRECTORY_SEPARATOR . $language . \DIRECTORY_SEPARATOR . $moduleName . '.' . static::FORMAT;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (isset(static::$languageContainer[$language][$moduleName]['js'])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return vsprintf(static::translate($key . $postfix, $moduleName), [$count]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param mixed $encode
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!$language) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return static::translateSingleMod($key, $moduleName, static::DEFAULT_LANG, $encode);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (0 === strpos($moduleName, 'Settings')) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param int $count Quantityu for plural determination
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($encode) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
static::$languageContainer[$language][$moduleName] = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
static::$languageContainer[$language][$moduleName] = Json::decode(file_get_contents($langFile), true) ?? [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function getFromFile($moduleName, $language)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
static::loadLanguageFile($language, $moduleName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Functions that gets translated string.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function getSingularModuleName($moduleName)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return "SINGLE_$moduleName";
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$langCustomFile = ROOT_DIRECTORY . \DIRECTORY_SEPARATOR . static::$customDirectory . $file;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return array
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (\is_array($args) && !empty($args)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (isset(static::$pluralizeCache[$count])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} else {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Get singular module name.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function loadLanguageFile($language, $moduleName = '_Base')
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $encode ? Purifier::encodeHtml($key) : $key;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$langFile = ROOT_DIRECTORY . $file;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$translation = Json::decode(file_get_contents($langCustomFile), true) ?? [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$return = static::$languageContainer[$language][$moduleName]['js'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @see https://docs.translatehouse.org/projects/localization-guide/en/latest/l10n/pluralforms.html?id=l10n/pluralforms#pluralforms-list
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (file_exists($langFile)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
static::$languageContainer[$language][$moduleName][$type][$key] = $val;
- Exclude checks
Line exceeds 120 characters; contains 135 characters Open
Cache::save('LanguageFiles', $language . $moduleName, static::$languageContainer[$language][$moduleName], Cache::LONG);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Get language from file.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return string[]
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$base = 'Settings' . \DIRECTORY_SEPARATOR . '_Base';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Functions that gets pluralized translated string.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function translateSingularModuleName($moduleName)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
static::$languageContainer[$language][$moduleName] = Cache::get('LanguageFiles', $language . $moduleName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} else {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Log::info("Language file does not exist, module: $moduleName ,language: $language");
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function getJsStrings($moduleName)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$moduleName = str_replace([':', '.'], [\DIRECTORY_SEPARATOR, \DIRECTORY_SEPARATOR], $moduleName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (Cache::has('LanguageFiles', $language . $moduleName)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
static::loadLanguageFile($language, $moduleName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$formattedString = \call_user_func_array('vsprintf', [$formattedString, $args]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function translatePluralized($key, $moduleName, $count)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$postfix = static::$pluralizeCache[$count];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $key
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$language = static::getLanguage();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return Purifier::encodeHtml(static::$languageContainer[$language][$moduleName]['php'][$key]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return static::$languageContainer[$language][$moduleName]['php'][$key];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $moduleName
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Translate singular module name.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $moduleName
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $moduleName
- Exclude checks
Line exceeds 120 characters; contains 128 characters Open
static::$languageContainer[$language][$moduleName] = Json::decode(file_get_contents($langFile), true) ?? [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (isset(static::$languageContainer[$language][$moduleName])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$args = \array_slice(\func_get_args(), 2);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function translateSingleMod($key, $moduleName = '_Base', $language = false, $encode = true)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return static::translate("SINGLE_$moduleName", $moduleName);
- Exclude checks
Line exceeds 120 characters; contains 122 characters Open
static::$languageContainer[$language][$moduleName] = Cache::get('LanguageFiles', $language . $moduleName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Cache::save('LanguageFiles', $language . $moduleName, static::$languageContainer[$language][$moduleName], Cache::LONG);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return static::$languageContainer[$language][$moduleName];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$language = static::getLanguage();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $key String which need to be translated
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$moduleName = str_replace([':', '.'], [\DIRECTORY_SEPARATOR, \DIRECTORY_SEPARATOR], $moduleName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (file_exists($langCustomFile)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($translation as $type => $rows) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($rows as $key => $val) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!file_exists($langFile) && !file_exists($langCustomFile)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $moduleName
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'nb', 'ne', 'nl', 'nn', 'nso', 'or', 'pa', 'pap', 'pms', 'ps', 'pt', 'rm', 'rw', 'sat', 'sco', 'sd', 'se', 'si', 'so', 'son', 'sq', 'sv', 'sw',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$j = $count % 100;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* - 3 or more forms : key_X with X indented for each plural form.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (\in_array($lang, ['ach', 'ak', 'am', 'arn', 'br', 'fa', 'fil', 'fr', 'gun', 'ln', 'mfe', 'mg', 'mi', 'oc', 'pt-BR', 'tg', 'ti', 'tr', 'uz', 'wa'])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return (1 !== $count) ? '_1' : '_0';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return '_0';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$j = $count % 100;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (1 === $i && 11 !== $j) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (8 !== $count && 11 !== $count) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
static::loadLanguageFile($language);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
//Two plural forms
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$i = $count % 10;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (2 === $count) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @see https://docs.translatehouse.org/projects/localization-guide/en/latest/l10n/pluralforms.html?id=l10n/pluralforms for whole plural rules used by getText
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return '_0';
- Exclude checks
Line exceeds 120 characters; contains 161 characters Open
if (\in_array($lang, ['ach', 'ak', 'am', 'arn', 'br', 'fa', 'fil', 'fr', 'gun', 'ln', 'mfe', 'mg', 'mi', 'oc', 'pt-BR', 'tg', 'ti', 'tr', 'uz', 'wa'])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'is':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (1 === $i && 11 !== $j) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return '_1';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'csb':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$i = $count % 10;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($i >= 2 && $i <= 4 && ($j < 10 || $j >= 20)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return '_1';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (isset(static::$languageContainer[$language][$base]['js'])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (isset(static::$languageContainer[$language]['_Base']['js'])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
private static function getPluralized($count)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} else {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
//No plural form
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (\in_array($lang, ['ay', 'bo', 'cgg', 'dz', 'id', 'ja', 'jbo', 'ka', 'km', 'ko', 'lo', 'ms', 'my', 'sah', 'su', 'th', 'tt', 'ug', 'vi', 'wo', 'zh'])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return (1 !== $count % 10 || 11 === $count % 100) ? '_1' : '_0';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($count >= 2 && $count <= 4) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'lv':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return '_2';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (1 === $count) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return '_1';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Line exceeds 120 characters; contains 162 characters Open
if (\in_array($lang, ['ay', 'bo', 'cgg', 'dz', 'id', 'ja', 'jbo', 'ka', 'km', 'ko', 'lo', 'ms', 'my', 'sah', 'su', 'th', 'tt', 'ug', 'vi', 'wo', 'zh'])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'ru':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (1 === $count) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'pl':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$i = $count % 10;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return '_2';
- Exclude checks
Line exceeds 120 characters; contains 162 characters Open
* @see https://docs.translatehouse.org/projects/localization-guide/en/latest/l10n/pluralforms.html?id=l10n/pluralforms for whole plural rules used by getText
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param float $count Quantityu for plural determination
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Line exceeds 120 characters; contains 166 characters Open
'af', 'an', 'anp', 'as', 'ast', 'az', 'bg', 'bn', 'brx', 'ca', 'da', 'de', 'doi', 'dz', 'el', 'en', 'eo', 'es', 'et', 'eu', 'ff', 'fi', 'fo', 'fur', 'fy',
- Exclude checks
Line exceeds 120 characters; contains 160 characters Open
'gl', 'gu', 'ha', 'he', 'hi', 'hne', 'hu', 'hy', 'ia', 'it', 'kk', 'kl', 'kn', 'ku', 'ky', 'lb', 'mai', 'mk', 'ml', 'mn', 'mni', 'mr', 'nah', 'nap',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
switch ($lang) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'uk':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$i = $count % 10;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return '_1';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return '_0';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (1 === $count) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'ro':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'bs':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (1 === $count) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return '_1';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return '_0';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return '_1';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return '_0';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Global patterns for keycode are as below :
- Exclude checks
Line exceeds 120 characters; contains 155 characters Open
'nb', 'ne', 'nl', 'nn', 'nso', 'or', 'pa', 'pap', 'pms', 'ps', 'pt', 'rm', 'rw', 'sat', 'sco', 'sd', 'se', 'si', 'so', 'son', 'sq', 'sv', 'sw',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'be':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'sr':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$j = $count % 100;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (1 == $i && 11 != $j) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$i = $count % 10;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $return;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* This function returns the modified keycode to match the plural form(s) of a given language and a given count with the same pattern used by i18next JS library
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* - No plural form : only one non modified key is needed :)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$j = $count % 100;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'lt':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return '_2';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$j = $count % 100;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
static::loadLanguageFile($language, $base);
- Exclude checks
Line exceeds 120 characters; contains 164 characters Open
* This function returns the modified keycode to match the plural form(s) of a given language and a given count with the same pattern used by i18next JS library
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return '_0';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($i >= 2 && ($j < 10 || $j >= 20)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (1 == $i && 11 != $j) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (0 !== $count) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return '_2';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return '_0';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return '_1';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'gl', 'gu', 'ha', 'he', 'hi', 'hne', 'hu', 'hy', 'ia', 'it', 'kk', 'kl', 'kn', 'ku', 'ky', 'lb', 'mai', 'mk', 'ml', 'mn', 'mni', 'mr', 'nah', 'nap',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'me':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$j = $count % 100;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($i >= 2 && $i <= 4 && ($j < 10 || $j >= 20)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'ta', 'te', 'tk', 'ur', 'yo',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($i >= 2 && $i <= 4 && ($j < 10 || $j >= 20)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return '_2';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'cs':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'sk':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return '_0';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return '_1';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return '_2';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return '_2';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$j = $count % 100;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (1 === $count) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$return = array_merge(static::$languageContainer[$language]['_Base']['js'], $return);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* - 2 forms : unmodified key for singular values and 'key_PLURAL' for plural values
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
//Extract language code from locale with special cases
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$lang = 'pt-BR';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return ($count > 1) ? '_1' : '_0';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return '_0';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return '_1';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return '_0';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (0 === $count || ($j > 0 && $j < 20)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$return = array_merge(static::$languageContainer[$language][$base]['js'], $return);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @see https://www.i18next.com/plurals.html for some examples
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return string Pluralized key to look for
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (0 === strcasecmp(static::getLanguage(), 'pt-BR')) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$lang = static::getShortLanguageName();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (\in_array($lang, [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'hr':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return '_2';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'cy':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'af', 'an', 'anp', 'as', 'ast', 'az', 'bg', 'bn', 'brx', 'ca', 'da', 'de', 'doi', 'dz', 'el', 'en', 'eo', 'es', 'et', 'eu', 'ff', 'fi', 'fo', 'fur', 'fy',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$i = $count % 10;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($i >= 2 && $i <= 4 && ($j < 10 || $j >= 20)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return '_3';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return '_3';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (1 === $count) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return '_0';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return '_0';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return '_2';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return '_1';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return '_3';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return '_3';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return array_column(Cache::get('getAllLanguages', $cacheKey), 'name', 'prefix');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$actives[$row['prefix']] = $row;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return Cache::save('getLangInfo', $prefix, (new Db\Query())->from('vtiger_language')->where(['prefix' => $prefix])->one());
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return '_0';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (1 === $count) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return static::getLangInfo($prefix)['name'] ?? null;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (Cache::has('getAllLanguages', $cacheKey)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return '_1';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return '_2';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'ga':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($count > 2 && $count < 7) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'ar':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (1 === $count) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return '';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dataReader = (new Db\Query())->from('vtiger_language')->createCommand()->query();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (2 === $count || 12 === $count) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return '_2';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return '_1';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return '_2';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Function to get the label name of the Langauge package.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return bool|string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$actives = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return array
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'gd':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$cacheKey = $active ? 'Active' : 'All';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return Cache::get('getLangInfo', $prefix);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'mt':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$j = $count % 100;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return '_3';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return '_5';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return Cache::get('getAllLanguages', $cacheKey);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return '_2';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return '_2';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($count * 100 >= 11) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $prefix
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (1 === (int) $row['active']) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Line exceeds 120 characters; contains 131 characters Open
return Cache::save('getLangInfo', $prefix, (new Db\Query())->from('vtiger_language')->where(['prefix' => $prefix])->one());
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (3 === $count) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $language
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (0 === $count) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Function return languages data.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$all[$row['prefix']] = $row;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dataReader->close();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return '_0';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param bool $allData
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!$allData) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Cache::save('getAllLanguages', 'All', $all);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Cache::save('getAllLanguages', 'Active', $actives);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($count > 2 && $count < 20) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (1 === $count) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return '_2';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (0 === $count || ($j > 1 && $j < 11)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return '_3';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (1 === $j) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'sl':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (2 === $j) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (3 === $j || 4 === $j) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (2 === $count) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return '_1';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return '_4';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (2 === $count) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return '_4';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
default:
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return '_1';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$all = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Cache::save('getLangInfo', $row['prefix'], $row);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param bool $active
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return array_column(Cache::get('getAllLanguages', $cacheKey), 'name', 'prefix');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function getLangInfo(string $prefix)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return array
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (Cache::has('getLangInfo', $prefix)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $prefix
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $fileName
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (1 === $count || 11 === $count) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'kw':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($j > 10 && $j < 20) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($count > 6 && $count < 11) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return '_0';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return '_1';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function getLanguageLabel(string $prefix)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function getAll(bool $active = true, bool $allData = false)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!$allData) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return Cache::get('getAllLanguages', $cacheKey);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Function return languange data.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Translation modification.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return '_3';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$j = $count % 100;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return '_0';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (2 === $count) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($count % 100 >= 3 && $count % 100 <= 10) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
while ($row = $dataReader->read()) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} else {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} else {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
unset($translations[$type][$label]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$defaultCharset = strtolower(\App\Config::main('default_charset'));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$loc .= \DIRECTORY_SEPARATOR . $name;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
LC_ALL,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (false !== strpos($localeSetting, '=')) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $type
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$loc = '';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
[$category, $locale] = explode('=', $localeSetting);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Line exceeds 120 characters; contains 205 characters Open
return Utils::mbUcfirst(locale_get_region($prefix) === strtoupper(locale_get_primary_language($prefix)) ? locale_get_display_language($prefix, $prefix) : locale_get_display_name($prefix, $prefix));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fileDirectory = ROOT_DIRECTORY . \DIRECTORY_SEPARATOR . implode(\DIRECTORY_SEPARATOR, $fileLocation) . '.' . static::FORMAT;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($fileLocation as $name) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $label
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
throw new Exceptions\AppException('ERR_NO_PERMISSIONS_TO_CREATE_DIRECTORIES');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\Locale::acceptFromHttp(self::DEFAULT_LANG) . ".$defaultCharset",
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $prefix
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($remove) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return locale_parse($prefix)['region'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Line exceeds 120 characters; contains 152 characters Open
public static function translationModify(string $language, string $fileName, string $type, string $label, string $translation, bool $remove = false)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fileLocation = explode('__', $fileName, 2);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
array_unshift($fileLocation, 'custom', 'languages', $language);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ('LC_COLLATE' !== $category && 'LC_CTYPE' !== $category && \defined($category)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $translation
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @throws Exceptions\AppException
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$translations = Json::decode(file_get_contents($fileDirectory), true);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (false === Json::save($fileDirectory, $translations)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Set locale information.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$original = explode(';', setlocale(LC_ALL, 0));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$locale = $localeSetting;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $prefix
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return mixed
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param bool $remove
- Exclude checks
Line exceeds 120 characters; contains 133 characters Open
$fileDirectory = ROOT_DIRECTORY . \DIRECTORY_SEPARATOR . implode(\DIRECTORY_SEPARATOR, $fileLocation) . '.' . static::FORMAT;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Cache::delete('LanguageFiles', $language . str_replace('__', \DIRECTORY_SEPARATOR, $fileName));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function initLocale()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\Locale::acceptFromHttp(self::getLanguage()) . '.' . $defaultCharset,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($original as $localeSetting) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$category = 'LC_ALL';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return Utils::mbUcfirst(locale_get_region($prefix) === strtoupper(locale_get_primary_language($prefix)) ? locale_get_display_language($prefix, $prefix) : locale_get_display_name($prefix, $prefix));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Get region from language prefix.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function getRegion(string $prefix)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (file_exists($fileDirectory)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
throw new Exceptions\AppException('ERR_CREATE_FILE_FAILURE');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
setlocale(
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Get display language name.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
array_pop($fileLocation);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!file_exists(ROOT_DIRECTORY . $loc) && !mkdir(ROOT_DIRECTORY . $loc, 0755)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$translations[$type][$label] = $translation;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
setlocale(\constant($category), $locale);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\Locale::acceptFromHttp(\App\Config::main('default_language')) . '.' . $defaultCharset,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function getDisplayName(string $prefix)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function translationModify(string $language, string $fileName, string $type, string $label, string $translation, bool $remove = false)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\Locale::acceptFromHttp(self::DEFAULT_LANG) . '.utf8'
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks