HuasoFoundries/jpgraph

View on GitHub
src/text/GB2312toUTF8.php

Summary

Maintainability
F
4 days
Test Coverage

File GB2312toUTF8.php has 1535 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
namespace Amenadiel\JpGraph\Text;

/**
 * File:        JPGRAPH_GB2312.PHP
Severity: Major
Found in src/text/GB2312toUTF8.php - About 4 days to fix

    The class GB2312toUTF8 has 1540 lines of code. Current threshold is 1000. Avoid really long classes.
    Open

    class GB2312toUTF8
    {
        // --------------------------------------------------------------------
        // This code table is used to translate GB2312 code (key) to
        // it's corresponding Unicode value (data)
    Severity: Minor
    Found in src/text/GB2312toUTF8.php by phpmd

    The method gb2utf8 uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
    Open

                } else {
                    $t  = substr($gb, 0, 1);
                    $gb = substr($gb, 1);
                    $utf8 .= $this->u2utf8($t);
                }
    Severity: Minor
    Found in src/text/GB2312toUTF8.php by phpmd

    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

        public function u2utf8($c)
    Severity: Minor
    Found in src/text/GB2312toUTF8.php by phpmd

    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

        public function gb2utf8($gb)
    Severity: Minor
    Found in src/text/GB2312toUTF8.php by phpmd

    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

                    $t  = substr($gb, 0, 2);
    Severity: Minor
    Found in src/text/GB2312toUTF8.php by phpmd

    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

    There are no issues that match your filters.

    Category
    Status