biurad/php-dependency-injection

View on GitHub
src/Adapters/XmlAdapter.php

Summary

Maintainability
D
3 days
Test Coverage

Function convertDomElementToArray has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
Open

    public function convertDomElementToArray(DOMElement $element, bool $checkPrefix = true)
    {
        $prefix = (string) $element->prefix;
        $empty  = true;
        $config = [];
Severity: Minor
Found in src/Adapters/XmlAdapter.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

Function addBranch has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
Open

    protected function addBranch($branchName, array $config, XMLWriter $writer): void
    {
        $branchType = null;

        foreach ($config as $key => $value) {
Severity: Minor
Found in src/Adapters/XmlAdapter.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

File XmlAdapter.php has 279 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

declare(strict_types=1);

/*
Severity: Minor
Found in src/Adapters/XmlAdapter.php - About 2 hrs to fix

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

        public function parse(string $content, $schemaOrCallable = null): DOMDocument
        {
            $internalErrors  = \libxml_use_internal_errors(true);
            \libxml_clear_errors();
    
    
    Severity: Minor
    Found in src/Adapters/XmlAdapter.php - About 1 hr 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 convertDomElementToArray has 42 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function convertDomElementToArray(DOMElement $element, bool $checkPrefix = true)
        {
            $prefix = (string) $element->prefix;
            $empty  = true;
            $config = [];
    Severity: Minor
    Found in src/Adapters/XmlAdapter.php - About 1 hr to fix

      Method addBranch has 41 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          protected function addBranch($branchName, array $config, XMLWriter $writer): void
          {
              $branchType = null;
      
              foreach ($config as $key => $value) {
      Severity: Minor
      Found in src/Adapters/XmlAdapter.php - About 1 hr to fix

        Method parse has 39 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function parse(string $content, $schemaOrCallable = null): DOMDocument
            {
                $internalErrors  = \libxml_use_internal_errors(true);
                \libxml_clear_errors();
        
        
        Severity: Minor
        Found in src/Adapters/XmlAdapter.php - About 1 hr to fix

          Method phpize has 28 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              protected function phpize($value)
              {
                  $value          = (string) $value;
                  $lowercaseValue = \strtolower($value);
          
          
          Severity: Minor
          Found in src/Adapters/XmlAdapter.php - About 1 hr to fix

            Method dump has 28 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function dump(array $data): string
                {
                    $writer = new XMLWriter();
                    $writer->openMemory();
                    $writer->setIndent(true);
            Severity: Minor
            Found in src/Adapters/XmlAdapter.php - About 1 hr to fix

              Avoid too many return statements within this method.
              Open

                              return (string) $value;
              Severity: Major
              Found in src/Adapters/XmlAdapter.php - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                                return (string) \bindec($value);
                Severity: Major
                Found in src/Adapters/XmlAdapter.php - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                                  return (string) (float) $value;
                  Severity: Major
                  Found in src/Adapters/XmlAdapter.php - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                                    return '0x' === $value[0] . $value[1] ? \hexdec($value) : (float) $value;
                    Severity: Major
                    Found in src/Adapters/XmlAdapter.php - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

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

                        Avoid too many return statements within this method.
                        Open

                                        return \hexdec($value);
                        Severity: Major
                        Found in src/Adapters/XmlAdapter.php - About 30 mins to fix

                          Avoid too many return statements within this method.
                          Open

                                          return (float) $value;
                          Severity: Major
                          Found in src/Adapters/XmlAdapter.php - About 30 mins to fix

                            Avoid too many return statements within this method.
                            Open

                                            return $value;
                            Severity: Major
                            Found in src/Adapters/XmlAdapter.php - About 30 mins to fix

                              Avoid too many return statements within this method.
                              Open

                                              return \hexdec($value);
                              Severity: Major
                              Found in src/Adapters/XmlAdapter.php - About 30 mins to fix

                                Avoid too many return statements within this method.
                                Open

                                                return \bindec($value);
                                Severity: Major
                                Found in src/Adapters/XmlAdapter.php - About 30 mins to fix

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

                                      public function dump(array $data): string
                                      {
                                          $writer = new XMLWriter();
                                          $writer->openMemory();
                                          $writer->setIndent(true);
                                  Severity: Minor
                                  Found in src/Adapters/XmlAdapter.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

                                  There are no issues that match your filters.

                                  Category
                                  Status