Function _loadTranslationData
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
public function _loadTranslationData($filename, $locale, array $options = [])
{
$this->_data = [];
$this->_bigEndian = false;
$this->_file = @fopen($filename, 'rb');
- 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 _loadTranslationData
has 64 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function _loadTranslationData($filename, $locale, array $options = [])
{
$this->_data = [];
$this->_bigEndian = false;
$this->_file = @fopen($filename, 'rb');
The method _loadTranslationData() has an NPath complexity of 264. The configured NPath complexity threshold is 200. Open
public function _loadTranslationData($filename, $locale, array $options = [])
{
$this->_data = [];
$this->_bigEndian = false;
$this->_file = @fopen($filename, 'rb');
- 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 _loadTranslationData() has a Cyclomatic Complexity of 12. The configured cyclomatic complexity threshold is 10. Open
public function _loadTranslationData($filename, $locale, array $options = [])
{
$this->_data = [];
$this->_bigEndian = false;
$this->_file = @fopen($filename, 'rb');
- 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
Remove error control operator '@' on line 136. Open
public function _loadTranslationData($filename, $locale, array $options = [])
{
$this->_data = [];
$this->_bigEndian = false;
$this->_file = @fopen($filename, 'rb');
- Read upRead up
- Exclude checks
ErrorControlOperator
Error suppression should be avoided if possible as it doesn't just suppress the error, that you are trying to stop, but will also suppress errors that you didn't predict would ever occur. Consider changing error_reporting() level and/or setting up your own error handler.
Example
function foo($filePath) {
$file = @fopen($filPath); // hides exceptions
$key = @$array[$notExistingKey]; // assigns null to $key
}
Source http://phpmd.org/rules/cleancode.html#errorcontroloperator
Remove error control operator '@' on line 144. Open
public function _loadTranslationData($filename, $locale, array $options = [])
{
$this->_data = [];
$this->_bigEndian = false;
$this->_file = @fopen($filename, 'rb');
- Read upRead up
- Exclude checks
ErrorControlOperator
Error suppression should be avoided if possible as it doesn't just suppress the error, that you are trying to stop, but will also suppress errors that you didn't predict would ever occur. Consider changing error_reporting() level and/or setting up your own error handler.
Example
function foo($filePath) {
$file = @fopen($filPath); // hides exceptions
$key = @$array[$notExistingKey]; // assigns null to $key
}
Source http://phpmd.org/rules/cleancode.html#errorcontroloperator
Remove error control operator '@' on line 159. Open
public function _loadTranslationData($filename, $locale, array $options = [])
{
$this->_data = [];
$this->_bigEndian = false;
$this->_file = @fopen($filename, 'rb');
- Read upRead up
- Exclude checks
ErrorControlOperator
Error suppression should be avoided if possible as it doesn't just suppress the error, that you are trying to stop, but will also suppress errors that you didn't predict would ever occur. Consider changing error_reporting() level and/or setting up your own error handler.
Example
function foo($filePath) {
$file = @fopen($filPath); // hides exceptions
$key = @$array[$notExistingKey]; // assigns null to $key
}
Source http://phpmd.org/rules/cleancode.html#errorcontroloperator
Missing class import via use statement (line '163', column '27'). Open
throw new Ajde_Exception('\''.$filename.'\' is not a gettext file');
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Remove error control operator '@' on line 143. Open
public function _loadTranslationData($filename, $locale, array $options = [])
{
$this->_data = [];
$this->_bigEndian = false;
$this->_file = @fopen($filename, 'rb');
- Read upRead up
- Exclude checks
ErrorControlOperator
Error suppression should be avoided if possible as it doesn't just suppress the error, that you are trying to stop, but will also suppress errors that you didn't predict would ever occur. Consider changing error_reporting() level and/or setting up your own error handler.
Example
function foo($filePath) {
$file = @fopen($filPath); // hides exceptions
$key = @$array[$notExistingKey]; // assigns null to $key
}
Source http://phpmd.org/rules/cleancode.html#errorcontroloperator
Remove error control operator '@' on line 212. Open
public function _loadTranslationData($filename, $locale, array $options = [])
{
$this->_data = [];
$this->_bigEndian = false;
$this->_file = @fopen($filename, 'rb');
- Read upRead up
- Exclude checks
ErrorControlOperator
Error suppression should be avoided if possible as it doesn't just suppress the error, that you are trying to stop, but will also suppress errors that you didn't predict would ever occur. Consider changing error_reporting() level and/or setting up your own error handler.
Example
function foo($filePath) {
$file = @fopen($filPath); // hides exceptions
$key = @$array[$notExistingKey]; // assigns null to $key
}
Source http://phpmd.org/rules/cleancode.html#errorcontroloperator
Missing class import via use statement (line '141', column '23'). Open
throw new Ajde_Exception('Error opening translation file \''.$filename.'\'.');
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '148', column '23'). Open
throw new Ajde_Exception('\''.$filename.'\' is not a gettext file');
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Remove error control operator '@' on line 190. Open
public function _loadTranslationData($filename, $locale, array $options = [])
{
$this->_data = [];
$this->_bigEndian = false;
$this->_file = @fopen($filename, 'rb');
- Read upRead up
- Exclude checks
ErrorControlOperator
Error suppression should be avoided if possible as it doesn't just suppress the error, that you are trying to stop, but will also suppress errors that you didn't predict would ever occur. Consider changing error_reporting() level and/or setting up your own error handler.
Example
function foo($filePath) {
$file = @fopen($filPath); // hides exceptions
$key = @$array[$notExistingKey]; // assigns null to $key
}
Source http://phpmd.org/rules/cleancode.html#errorcontroloperator
Missing class import via use statement (line '22', column '31'). Open
$this->_gettext = new Zend_Translate_Adapter_Gettext();
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
The method _readMOData uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
return unpack('N'.$bytes, fread($this->_file, 4 * $bytes));
}
- 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
The method _loadTranslationData uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
@fclose($this->_file);
// AJDE : Changed to use Ajde_Exception
// require_once 'Zend/Translate/Exception.php';
// throw new Zend_Translate_Exception('\'' . $filename . '\' is not a gettext file');
- 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
The method _loadTranslationData uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$this->_adapterInfo[$filename] = $this->_data[$locale][''];
}
- 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
The method _loadTranslationData uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
if (strtolower(substr(dechex($input[1]), -8)) == 'de120495') {
$this->_bigEndian = true;
} else {
@fclose($this->_file);
- 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
The method _loadTranslationData uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$original[0] = '';
}
- 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
The method get uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$this->log($ident, $module);
return $ident;
}
- 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
The method _loadTranslationData uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$this->_data[$locale][$original[0]] = $translate[0];
}
- 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 unused parameters such as '$options'. Open
public function _loadTranslationData($filename, $locale, array $options = [])
- Read upRead up
- Exclude checks
UnusedFormalParameter
Since: 0.2
Avoid passing parameters to methods or constructors and then not using those parameters.
Example
class Foo
{
private function bar($howdy)
{
// $howdy is not used
}
}
Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter
TODO found Open
// // TODO: now this adapter is not working properly...
- Exclude checks
The property $_dictionary is not named in camelCase. Open
class Ajde_Lang_Adapter_Gettext extends Ajde_Lang_Adapter_Abstract
{
protected $_gettext;
protected $_lang;
protected $_dictionary;
- Read upRead up
- Exclude checks
CamelCasePropertyName
Since: 0.2
It is considered best practice to use the camelCase notation to name attributes.
Example
class ClassName {
protected $property_name;
}
Source
The property $_file is not named in camelCase. Open
class Zend_Translate_Adapter_Gettext extends Ajde_Object_Standard
{
// Internal variables
private $_bigEndian = false;
private $_file = false;
- Read upRead up
- Exclude checks
CamelCasePropertyName
Since: 0.2
It is considered best practice to use the camelCase notation to name attributes.
Example
class ClassName {
protected $property_name;
}
Source
The property $_gettext is not named in camelCase. Open
class Ajde_Lang_Adapter_Gettext extends Ajde_Lang_Adapter_Abstract
{
protected $_gettext;
protected $_lang;
protected $_dictionary;
- Read upRead up
- Exclude checks
CamelCasePropertyName
Since: 0.2
It is considered best practice to use the camelCase notation to name attributes.
Example
class ClassName {
protected $property_name;
}
Source
The class Ajde_Lang_Adapter_Gettext is not named in CamelCase. Open
class Ajde_Lang_Adapter_Gettext extends Ajde_Lang_Adapter_Abstract
{
protected $_gettext;
protected $_lang;
protected $_dictionary;
- Read upRead up
- Exclude checks
CamelCaseClassName
Since: 0.2
It is considered best practice to use the CamelCase notation to name classes.
Example
class class_name {
}
Source
The property $_adapterInfo is not named in camelCase. Open
class Zend_Translate_Adapter_Gettext extends Ajde_Object_Standard
{
// Internal variables
private $_bigEndian = false;
private $_file = false;
- Read upRead up
- Exclude checks
CamelCasePropertyName
Since: 0.2
It is considered best practice to use the camelCase notation to name attributes.
Example
class ClassName {
protected $property_name;
}
Source
The property $_bigEndian is not named in camelCase. Open
class Zend_Translate_Adapter_Gettext extends Ajde_Object_Standard
{
// Internal variables
private $_bigEndian = false;
private $_file = false;
- Read upRead up
- Exclude checks
CamelCasePropertyName
Since: 0.2
It is considered best practice to use the camelCase notation to name attributes.
Example
class ClassName {
protected $property_name;
}
Source
The property $_data is not named in camelCase. Open
class Zend_Translate_Adapter_Gettext extends Ajde_Object_Standard
{
// Internal variables
private $_bigEndian = false;
private $_file = false;
- Read upRead up
- Exclude checks
CamelCasePropertyName
Since: 0.2
It is considered best practice to use the camelCase notation to name attributes.
Example
class ClassName {
protected $property_name;
}
Source
The property $_lang is not named in camelCase. Open
class Ajde_Lang_Adapter_Gettext extends Ajde_Lang_Adapter_Abstract
{
protected $_gettext;
protected $_lang;
protected $_dictionary;
- Read upRead up
- Exclude checks
CamelCasePropertyName
Since: 0.2
It is considered best practice to use the camelCase notation to name attributes.
Example
class ClassName {
protected $property_name;
}
Source
The class Zend_Translate_Adapter_Gettext is not named in CamelCase. Open
class Zend_Translate_Adapter_Gettext extends Ajde_Object_Standard
{
// Internal variables
private $_bigEndian = false;
private $_file = false;
- Read upRead up
- Exclude checks
CamelCaseClassName
Since: 0.2
It is considered best practice to use the CamelCase notation to name classes.
Example
class class_name {
}
Source
The variable $TOffset is not named in camelCase. Open
public function _loadTranslationData($filename, $locale, array $options = [])
{
$this->_data = [];
$this->_bigEndian = false;
$this->_file = @fopen($filename, 'rb');
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $TOffset is not named in camelCase. Open
public function _loadTranslationData($filename, $locale, array $options = [])
{
$this->_data = [];
$this->_bigEndian = false;
$this->_file = @fopen($filename, 'rb');
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $OOffset is not named in camelCase. Open
public function _loadTranslationData($filename, $locale, array $options = [])
{
$this->_data = [];
$this->_bigEndian = false;
$this->_file = @fopen($filename, 'rb');
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $OOffset is not named in camelCase. Open
public function _loadTranslationData($filename, $locale, array $options = [])
{
$this->_data = [];
$this->_bigEndian = false;
$this->_file = @fopen($filename, 'rb');
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The method _loadTranslationData is not named in camelCase. Open
public function _loadTranslationData($filename, $locale, array $options = [])
{
$this->_data = [];
$this->_bigEndian = false;
$this->_file = @fopen($filename, 'rb');
- Read upRead up
- Exclude checks
CamelCaseMethodName
Since: 0.2
It is considered best practice to use the camelCase notation to name methods.
Example
class ClassName {
public function get_name() {
}
}
Source
The method _readMOData is not named in camelCase. Open
private function _readMOData($bytes)
{
if ($this->_bigEndian === false) {
return unpack('V'.$bytes, fread($this->_file, 4 * $bytes));
} else {
- Read upRead up
- Exclude checks
CamelCaseMethodName
Since: 0.2
It is considered best practice to use the camelCase notation to name methods.
Example
class ClassName {
public function get_name() {
}
}