ideasonpurpose/wp-svg-lib

View on GitHub

Showing 8 of 9 total issues

File SVG.php has 375 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
namespace IdeasOnPurpose\WP;

use Doctrine\Inflector\InflectorFactory;

Severity: Minor
Found in src/SVG.php - About 5 hrs to fix

    SVG has 24 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class SVG
    {
        use Deprecated\Directory;
        use Deprecated\DumpSymbols;
        use Deprecated\Get;
    Severity: Minor
    Found in src/SVG.php - About 2 hrs to fix

      Method rewrapSvg has 45 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function rewrapSvg($svg, $attributes = [])
          {
              $esc_atts = array_map('urlencode', $attributes);
              $svg->_links->self = add_query_arg($esc_atts, $svg->_links->self);
              $svg->_links->svg = add_query_arg($esc_atts, $svg->_links->svg);
      Severity: Minor
      Found in src/SVG.php - About 1 hr to fix

        Method normalizeSvg has 38 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function normalizeSvg($rawSVGString)
            {
                libxml_use_internal_errors(true);
                $xml = simplexml_load_string(trim($rawSVGString));
        
        
        Severity: Minor
        Found in src/SVG.php - About 1 hr to fix

          Function rewrapSvg has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

              public function rewrapSvg($svg, $attributes = [])
              {
                  $esc_atts = array_map('urlencode', $attributes);
                  $svg->_links->self = add_query_arg($esc_atts, $svg->_links->self);
                  $svg->_links->svg = add_query_arg($esc_atts, $svg->_links->svg);
          Severity: Minor
          Found in src/SVG.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 dumpSymbols has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function dumpSymbols()
              {
                  echo "\n\n<!-- SVG:dumpSymbols is deprecated. View the full list of SVGs from the Rest API. -->\n";
          
                  if (count($this->inUse)) {
          Severity: Minor
          Found in src/Deprecated/DumpSymbols.php - About 1 hr to fix

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

                public function dumpSymbols()
                {
                    echo "\n\n<!-- SVG:dumpSymbols is deprecated. View the full list of SVGs from the Rest API. -->\n";
            
                    if (count($this->inUse)) {
            Severity: Minor
            Found in src/Deprecated/DumpSymbols.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 normalizeSvg has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                public function normalizeSvg($rawSVGString)
                {
                    libxml_use_internal_errors(true);
                    $xml = simplexml_load_string(trim($rawSVGString));
            
            
            Severity: Minor
            Found in src/SVG.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