opnmind/php-svg

View on GitHub

Showing 12 of 35 total issues

Method parseColor has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public static function parseColor($color)
    {
        $colorLower = strtolower($color);
        if (isset(self::$namedColors[$colorLower])) {
            return self::$namedColors[$colorLower];
Severity: Minor
Found in src/SVG.php - About 1 hr to fix

    Method renderStroke has 31 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        protected function renderStroke($image, array $params, $color, $strokeWidth)
        {
            imagesetthickness($image, $strokeWidth);
    
            $x1 = $params['x1'];
    Severity: Minor
    Found in src/Rasterization/Renderers/SVGRectRenderer.php - About 1 hr to fix

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

          public function __construct($x1 = null, $y1 = null, $x2 = null, $y2 = null, $text = null, $fontsize = null, $color = null, $fontfile = null)
      Severity: Major
      Found in src/Nodes/Shapes/SVGTextBox.php - About 1 hr to fix

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

            public function getSerializableAttributes()
            {
                $attrs = parent::getSerializableAttributes();
        
                if ($this->root) {
        Severity: Minor
        Found in src/Nodes/Structures/SVGDocumentFragment.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 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            public function __construct($x = null, $y = null, $text1 = null, $fontsize = null, $color = null, $fontfile = null)
        Severity: Minor
        Found in src/Nodes/Shapes/SVGText.php - About 45 mins to fix

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

              private static function calculateCubic($p0, $p1, $p2, $p3, $t)
          Severity: Minor
          Found in src/Rasterization/Path/SVGBezierApproximator.php - About 35 mins to fix

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

                public function cubic($p0, $p1, $p2, $p3, $accuracy = 1)
            Severity: Minor
            Found in src/Rasterization/Path/SVGBezierApproximator.php - About 35 mins to fix

              Function parseCommandChain has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  private function parseCommandChain($id, array $args, array &$commands)
                  {
                      if (!isset(self::$commandLengths[$id])) {
                          // unknown command
                          return false;
              Severity: Minor
              Found in src/Rasterization/Path/SVGPathParser.php - About 35 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

              Function applyAttributes has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  private function applyAttributes(SVGNode $node, \SimpleXMLElement $xml)
                  {
                      foreach ($xml->attributes() as $key => $value) {
                          if ($key === 'style') {
                              continue;
              Severity: Minor
              Found in src/Reading/SVGReader.php - About 35 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

              Avoid too many return statements within this method.
              Open

                      return;
              Severity: Major
              Found in src/SVG.php - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                        return true;
                Severity: Major
                Found in src/Rasterization/Path/SVGPathParser.php - About 30 mins to fix

                  Function approximate has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function approximate(array $cmds)
                      {
                          $subpaths = array();
                  
                          $posX = 0;
                  Severity: Minor
                  Found in src/Rasterization/Path/SVGPathApproximator.php - About 25 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

                  Severity
                  Category
                  Status
                  Source
                  Language