HuasoFoundries/jpgraph

View on GitHub
src/text/CanvasRectangleText.php

Summary

Maintainability
B
4 hrs
Test Coverage

Method Stroke has 55 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function Stroke($aImg, $scale)
    {
        // If coordinates are specifed as negative this means we should
        // treat them as abolsute (pixels) coordinates
        if ($this->ix > 0) {
Severity: Major
Found in src/text/CanvasRectangleText.php - About 2 hrs to fix

    Function Stroke has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        public function Stroke($aImg, $scale)
        {
            // If coordinates are specifed as negative this means we should
            // treat them as abolsute (pixels) coordinates
            if ($this->ix > 0) {
    Severity: Minor
    Found in src/text/CanvasRectangleText.php - About 55 mins to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Method __construct has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        public function __construct($aTxt = '', $xl = 0, $yt = 0, $w = 0, $h = 0)
    Severity: Minor
    Found in src/text/CanvasRectangleText.php - About 35 mins to fix

      Method Set has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          public function Set($aTxt, $xl, $yt, $w = 0, $h = 0)
      Severity: Minor
      Found in src/text/CanvasRectangleText.php - About 35 mins to fix

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

                } else {
                    $this->iy = -$this->iy;
                }
        Severity: Minor
        Found in src/text/CanvasRectangleText.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

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

                } else {
                    $this->ix = -$this->ix;
                }
        Severity: Minor
        Found in src/text/CanvasRectangleText.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 $w. Configured minimum length is 3.
        Open

            public function Pos($xl = 0, $yt = 0, $w = 0, $h = 0)
        Severity: Minor
        Found in src/text/CanvasRectangleText.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 $ih. Configured minimum length is 3.
        Open

            private $ih;
        Severity: Minor
        Found in src/text/CanvasRectangleText.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 $h. Configured minimum length is 3.
        Open

            public function Set($aTxt, $xl, $yt, $w = 0, $h = 0)
        Severity: Minor
        Found in src/text/CanvasRectangleText.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 $xl. Configured minimum length is 3.
        Open

            public function SetPos($xl = 0, $yt = 0, $w = 0, $h = 0)
        Severity: Minor
        Found in src/text/CanvasRectangleText.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 $h. Configured minimum length is 3.
        Open

            public function SetPos($xl = 0, $yt = 0, $w = 0, $h = 0)
        Severity: Minor
        Found in src/text/CanvasRectangleText.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 $yt. Configured minimum length is 3.
        Open

            public function Pos($xl = 0, $yt = 0, $w = 0, $h = 0)
        Severity: Minor
        Found in src/text/CanvasRectangleText.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 $w. Configured minimum length is 3.
        Open

            public function SetPos($xl = 0, $yt = 0, $w = 0, $h = 0)
        Severity: Minor
        Found in src/text/CanvasRectangleText.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 $h. Configured minimum length is 3.
        Open

            public function Pos($xl = 0, $yt = 0, $w = 0, $h = 0)
        Severity: Minor
        Found in src/text/CanvasRectangleText.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 $w. Configured minimum length is 3.
        Open

            public function __construct($aTxt = '', $xl = 0, $yt = 0, $w = 0, $h = 0)
        Severity: Minor
        Found in src/text/CanvasRectangleText.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 $xl. Configured minimum length is 3.
        Open

            public function Set($aTxt, $xl, $yt, $w = 0, $h = 0)
        Severity: Minor
        Found in src/text/CanvasRectangleText.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 $yt. Configured minimum length is 3.
        Open

            public function Set($aTxt, $xl, $yt, $w = 0, $h = 0)
        Severity: Minor
        Found in src/text/CanvasRectangleText.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 $iy. Configured minimum length is 3.
        Open

            private $iy;
        Severity: Minor
        Found in src/text/CanvasRectangleText.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 $w. Configured minimum length is 3.
        Open

            public function Set($aTxt, $xl, $yt, $w = 0, $h = 0)
        Severity: Minor
        Found in src/text/CanvasRectangleText.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 $yt. Configured minimum length is 3.
        Open

            public function __construct($aTxt = '', $xl = 0, $yt = 0, $w = 0, $h = 0)
        Severity: Minor
        Found in src/text/CanvasRectangleText.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 $yt. Configured minimum length is 3.
        Open

            public function SetPos($xl = 0, $yt = 0, $w = 0, $h = 0)
        Severity: Minor
        Found in src/text/CanvasRectangleText.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 $xl. Configured minimum length is 3.
        Open

            public function Pos($xl = 0, $yt = 0, $w = 0, $h = 0)
        Severity: Minor
        Found in src/text/CanvasRectangleText.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 $ir. Configured minimum length is 3.
        Open

            private $ir = 4;
        Severity: Minor
        Found in src/text/CanvasRectangleText.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 $xl. Configured minimum length is 3.
        Open

            public function __construct($aTxt = '', $xl = 0, $yt = 0, $w = 0, $h = 0)
        Severity: Minor
        Found in src/text/CanvasRectangleText.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 $ix. Configured minimum length is 3.
        Open

            private $ix;
        Severity: Minor
        Found in src/text/CanvasRectangleText.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 $h. Configured minimum length is 3.
        Open

            public function __construct($aTxt = '', $xl = 0, $yt = 0, $w = 0, $h = 0)
        Severity: Minor
        Found in src/text/CanvasRectangleText.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 $iw. Configured minimum length is 3.
        Open

            private $iw;
        Severity: Minor
        Found in src/text/CanvasRectangleText.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

        Method name "CanvasRectangleText::SetAutoMargin" is not in camel caps format
        Open

            public function SetAutoMargin($aMargin)

        Method name "CanvasRectangleText::SetColor" is not in camel caps format
        Open

            public function SetColor($aColor)

        Method name "CanvasRectangleText::SetShadow" is not in camel caps format
        Open

            public function SetShadow($aColor = 'gray', $aWidth = 3)

        Method name "CanvasRectangleText::SetCornerRadius" is not in camel caps format
        Open

            public function SetCornerRadius($aRad = 5)

        Method name "CanvasRectangleText::SetPos" is not in camel caps format
        Open

            public function SetPos($xl = 0, $yt = 0, $w = 0, $h = 0)

        Method name "CanvasRectangleText::SetFont" is not in camel caps format
        Open

            public function SetFont($FontFam, $aFontStyle, $aFontSize = 12)

        Method name "CanvasRectangleText::ParagraphAlign" is not in camel caps format
        Open

            public function ParagraphAlign($aParaAlign)

        Method name "CanvasRectangleText::SetFillColor" is not in camel caps format
        Open

            public function SetFillColor($aFillColor)

        Method name "CanvasRectangleText::SetFontColor" is not in camel caps format
        Open

            public function SetFontColor($aColor)

        Method name "CanvasRectangleText::Set" is not in camel caps format
        Open

            public function Set($aTxt, $xl, $yt, $w = 0, $h = 0)

        Method name "CanvasRectangleText::SetTxt" is not in camel caps format
        Open

            public function SetTxt($aTxt)

        Method name "CanvasRectangleText::Stroke" is not in camel caps format
        Open

            public function Stroke($aImg, $scale)

        Method name "CanvasRectangleText::Pos" is not in camel caps format
        Open

            public function Pos($xl = 0, $yt = 0, $w = 0, $h = 0)

        There are no issues that match your filters.

        Category
        Status