hnhdigital-os/laravel-html-generator

View on GitHub

Showing 16 of 68 total issues

File Html.php has 819 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace HnhDigital\LaravelHtmlGenerator;

use Illuminate\Support\Arr;
Severity: Major
Found in src/Html.php - About 1 day to fix

    Html has 96 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Html extends Markup
    {
        /**
         * @param string       $tag
         * @param array<mixed> $arguments
    Severity: Major
    Found in src/Html.php - About 1 day to fix

      Function addOptionsArray has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
      Open

          public function addOptionsArray(
              array $data,
              bool|string $data_value,
              bool|string|null $data_name,
              array|string|null $selected_value = []
      Severity: Minor
      Found in src/Html.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 attributesToString has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function attributesToString(): string
          {
              $string = '';
              $XMLConvention = in_array(static::$outputLanguage, [ENT_XML1, ENT_XHTML]);
              if (!empty($this->attributeList)) {
      Severity: Minor
      Found in src/Markup.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

      Markup has 23 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class Markup implements ArrayAccess
      {
          /**
           * Specifies if attribute values and text input sould be protected from XSS injection.
           */
      Severity: Minor
      Found in src/Markup.php - About 2 hrs to fix

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

            public function addClass(array|string|null $value = ''): self
            {
                if (blank($value)) {
                    return $this;
                }
        Severity: Minor
        Found in src/Html.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 addOptionsArray has 36 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function addOptionsArray(
                array $data,
                bool|string $data_value,
                bool|string|null $data_name,
                array|string|null $selected_value = []
        Severity: Minor
        Found in src/Html.php - About 1 hr to fix

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

              public static function createElement($tag = '', $attributes1 = [], $attributes2 = []): static
              {
                  $tag_object = parent::createElement($tag);
          
                  $tag_object->setTag($tag);
          Severity: Minor
          Found in src/Html.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 addClass has 30 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function addClass(array|string|null $value = ''): self
              {
                  if (blank($value)) {
                      return $this;
                  }
          Severity: Minor
          Found in src/Html.php - About 1 hr to fix

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

                public static function icon(string $icon, string|int $size = 0, string $tag = 'i'): self
                {
                    $icon = preg_replace('/(")(.*?)(")/', '$2', $icon);
            
                    $icon_array = explode(',', $icon, 2);
            Severity: Minor
            Found in src/Html.php - About 1 hr to fix

              Function getNext has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function getNext(): ?self
                  {
                      $next = null;
                      $find = false;
                      if (!is_null($this->parent)) {
              Severity: Minor
              Found in src/Markup.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 icon has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

                  public static function icon(string $icon, string|int $size = 0, string $tag = 'i'): self
                  {
                      $icon = preg_replace('/(")(.*?)(")/', '$2', $icon);
              
                      $icon_array = explode(',', $icon, 2);
              Severity: Minor
              Found in src/Html.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 routeLink has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                  public static function routeLink(
                      ?string $text = null,
                      ?string $route = null,
                      array $parameters = [],
                      array $link_attributes = [],
              Severity: Minor
              Found in src/Html.php - About 45 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 routeLink has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                      ?string $text = null,
                      ?string $route = null,
                      array $parameters = [],
                      array $link_attributes = [],
                      string $extra_link = ''
              Severity: Minor
              Found in src/Html.php - About 35 mins to fix

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

                    public function getPrevious(): ?static
                    {
                        $prev = $this;
                
                        if (!is_null($this->parent)) {
                Severity: Minor
                Found in src/Markup.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 remove has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function remove(): ?self
                    {
                        $parent = $this->parent;
                
                        if (!is_null($parent)) {
                Severity: Minor
                Found in src/Markup.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