hnhdigital-os/laravel-html-builder

View on GitHub

Showing 10 of 20 total issues

File Tag.php has 305 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace HnhDigital\LaravelHtmlBuilder;

use HnhDigital\LaravelHtmlGenerator\Html;
Severity: Minor
Found in src/Tag.php - About 3 hrs to fix

    Tag has 27 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Tag
    {
        private static $tag_registry = [];
        private static $special_tags = [
            'img', 'br', 'hr', 'input', 'area', 'link', 'meta', 'param',
    Severity: Minor
    Found in src/Tag.php - About 3 hrs to fix

      Function buildHtml has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

          private static function buildHtml(&$html, $tag_object, $options, $tab = 0)
          {
              self::checkBuildOptions($options);
      
              $tag_is_special = in_array($tag_object->getTag(), self::$special_tags);
      Severity: Minor
      Found in src/Tag.php - About 2 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 buildArray has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

          private static function buildArray(&$array, $tag_object, $options = [])
          {
              self::checkBuildOptions($options);
      
              if (in_array($tag_object->getTag(), self::$special_tags)) {
      Severity: Minor
      Found in src/Tag.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

      Function add has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

          public function add($tag, ...$arguments)
          {
              $tag = strtolower($tag);
              $text = '';
              $attributes = [];
      Severity: Minor
      Found in src/Tag.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 buildHtml has 40 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private static function buildHtml(&$html, $tag_object, $options, $tab = 0)
          {
              self::checkBuildOptions($options);
      
              $tag_is_special = in_array($tag_object->getTag(), self::$special_tags);
      Severity: Minor
      Found in src/Tag.php - About 1 hr to fix

        Method add has 36 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function add($tag, ...$arguments)
            {
                $tag = strtolower($tag);
                $text = '';
                $attributes = [];
        Severity: Minor
        Found in src/Tag.php - About 1 hr to fix

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

              public static function buildFromArray(&$html, $array, $tab = 0)
              {
                  $pad = '';
                  if ($tab > 0) {
                      $pad = str_pad($pad, $tab * 2, ' ', STR_PAD_LEFT);
          Severity: Minor
          Found in src/Tag.php - About 1 hr to fix

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

                public static function buildFromArray(&$html, $array, $tab = 0)
                {
                    $pad = '';
                    if ($tab > 0) {
                        $pad = str_pad($pad, $tab * 2, ' ', STR_PAD_LEFT);
            Severity: Minor
            Found in src/Tag.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 buildHtmlAttribute has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                private static function buildHtmlAttribute($attributes)
                {
                    $html = '';
                    foreach ($attributes as $name => $value) {
                        if (is_array($value)) {
            Severity: Minor
            Found in src/Tag.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

            Severity
            Category
            Status
            Source
            Language