GreenCape/xml-converter

View on GitHub
src/GreenCape/XML/Converter.php

Summary

Maintainability
D
1 day
Test Coverage
B
87%

Function traverse has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
Open

    private function traverse($node, int $level = 0): string
    {
        $xml        = '';
        $attributes = '';
        $indent     = str_repeat('    ', $level);
Severity: Minor
Found in src/GreenCape/XML/Converter.php - About 3 hrs 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

Converter has 26 functions (exceeds 20 allowed). Consider refactoring.
Open

class Converter implements \Iterator, \ArrayAccess
{
    public  $xml           = '';

    public  $data          = [];
Severity: Minor
Found in src/GreenCape/XML/Converter.php - About 3 hrs to fix

    File Converter.php has 267 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    /**
     * GreenCape XML Converter
     *
     * MIT License
    Severity: Minor
    Found in src/GreenCape/XML/Converter.php - About 2 hrs to fix

      Method traverse has 46 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function traverse($node, int $level = 0): string
          {
              $xml        = '';
              $attributes = '';
              $indent     = str_repeat('    ', $level);
      Severity: Minor
      Found in src/GreenCape/XML/Converter.php - About 1 hr to fix

        Method handleElementOpen has 29 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private function handleElementOpen(Stream $stream): void
            {
                // Skip '<'
                $stream->next();
                $element = $stream->readTo('>');
        Severity: Minor
        Found in src/GreenCape/XML/Converter.php - About 1 hr to fix

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

              private function parse(): void
              {
                  $this->stack[] =& $this->data;
                  $stream        = new Stream(trim($this->xml));
          
          
          Severity: Minor
          Found in src/GreenCape/XML/Converter.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

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

              private function handleElementOpen(Stream $stream): void
              {
                  // Skip '<'
                  $stream->next();
                  $element = $stream->readTo('>');
          Severity: Minor
          Found in src/GreenCape/XML/Converter.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

          There are no issues that match your filters.

          Category
          Status