src/text/GB2312toUTF8.php
File GB2312toUTF8.php
has 1535 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
<?php
namespace Amenadiel\JpGraph\Text;
/**
* File: JPGRAPH_GB2312.PHP
The class GB2312toUTF8 has 1540 lines of code. Current threshold is 1000. Avoid really long classes. Open
Open
class GB2312toUTF8
{
// --------------------------------------------------------------------
// This code table is used to translate GB2312 code (key) to
// it's corresponding Unicode value (data)
- Exclude checks
The method gb2utf8 uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
Open
} else {
$t = substr($gb, 0, 1);
$gb = substr($gb, 1);
$utf8 .= $this->u2utf8($t);
}
- 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 variables with short names like $c. Configured minimum length is 3. Open
Open
public function u2utf8($c)
- 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 $gb. Configured minimum length is 3. Open
Open
public function gb2utf8($gb)
- 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 $t. Configured minimum length is 3. Open
Open
$t = substr($gb, 0, 2);
- 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;
}
}
}