hnhdigital-os/laravel-html-generator

View on GitHub

Showing 68 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

      The class Html has an overall complexity of 228 which is very high. The configured complexity threshold is 50.
      Open

      class Html extends Markup
      {
          /**
           * @param string       $tag
           * @param array<mixed> $arguments
      Severity: Minor
      Found in src/Html.php by phpmd

      The class Markup has an overall complexity of 56 which is very high. The configured complexity threshold is 50.
      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 by phpmd

      The class Html has 91 non-getter- and setter-methods. Consider refactoring Html to keep number of methods under 25.
      Open

      class Html extends Markup
      {
          /**
           * @param string       $tag
           * @param array<mixed> $arguments
      Severity: Minor
      Found in src/Html.php by phpmd

      TooManyMethods

      Since: 0.1

      A class with too many methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.

      By default it ignores methods starting with 'get' or 'set'.

      The default was changed from 10 to 25 in PHPMD 2.3.

      Example

      Source https://phpmd.org/rules/codesize.html#toomanymethods

      The class Html has 90 public methods. Consider refactoring Html to keep number of public methods under 10.
      Open

      class Html extends Markup
      {
          /**
           * @param string       $tag
           * @param array<mixed> $arguments
      Severity: Minor
      Found in src/Html.php by phpmd

      TooManyPublicMethods

      Since: 0.1

      A class with too many public methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.

      By default it ignores methods starting with 'get' or 'set'.

      Example

      Source https://phpmd.org/rules/codesize.html#toomanypublicmethods

      The class Markup has 13 public methods. Consider refactoring Markup to keep number of public methods under 10.
      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 by phpmd

      TooManyPublicMethods

      Since: 0.1

      A class with too many public methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.

      By default it ignores methods starting with 'get' or 'set'.

      Example

      Source https://phpmd.org/rules/codesize.html#toomanypublicmethods

      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

          Avoid using short method names like Html::on(). The configured minimum method name length is 3.
          Open

              public function on(?string $name = null, ?string $value = null): self
              {
                  if (is_null($name) || is_null($value)) {
                      return $this;
                  }
          Severity: Minor
          Found in src/Html.php by phpmd

          ShortMethodName

          Since: 0.2

          Detects when very short method names are used.

          Example

          class ShortMethod {
              public function a( $index ) { // Violation
              }
          }

          Source https://phpmd.org/rules/naming.html#shortmethodname

          Avoid using short method names like Html::s(). The configured minimum method name length is 3.
          Open

              public function s(\Closure|string|bool|null $value = true): string
              {
                  if (is_callable($value)) {
                      $value = $value();
                  }
          Severity: Minor
          Found in src/Html.php by phpmd

          ShortMethodName

          Since: 0.2

          Detects when very short method names are used.

          Example

          class ShortMethod {
              public function a( $index ) { // Violation
              }
          }

          Source https://phpmd.org/rules/naming.html#shortmethodname

          Avoid using short method names like Html::td(). The configured minimum method name length is 3.
          Open

              public static function td(mixed ...$arguments): self
              {
                  array_unshift($arguments, 'td');
          
                  return self::createElement(...$arguments);
          Severity: Minor
          Found in src/Html.php by phpmd

          ShortMethodName

          Since: 0.2

          Detects when very short method names are used.

          Example

          class ShortMethod {
              public function a( $index ) { // Violation
              }
          }

          Source https://phpmd.org/rules/naming.html#shortmethodname

          Avoid using short method names like Html::a(). The configured minimum method name length is 3.
          Open

              public static function a(mixed ...$arguments): self
              {
                  array_unshift($arguments, 'a');
          
                  return self::createElement(...$arguments);
          Severity: Minor
          Found in src/Html.php by phpmd

          ShortMethodName

          Since: 0.2

          Detects when very short method names are used.

          Example

          class ShortMethod {
              public function a( $index ) { // Violation
              }
          }

          Source https://phpmd.org/rules/naming.html#shortmethodname

          Avoid using short method names like Html::tr(). The configured minimum method name length is 3.
          Open

              public static function tr(mixed ...$arguments): self
              {
                  array_unshift($arguments, 'tr');
          
                  return self::createElement(...$arguments);
          Severity: Minor
          Found in src/Html.php by phpmd

          ShortMethodName

          Since: 0.2

          Detects when very short method names are used.

          Example

          class ShortMethod {
              public function a( $index ) { // Violation
              }
          }

          Source https://phpmd.org/rules/naming.html#shortmethodname

          Avoid using short method names like Html::id(). The configured minimum method name length is 3.
          Open

              public function id(string|int|null $value = null): self
              {
                  if (is_null($value)) {
                      return $this;
                  }
          Severity: Minor
          Found in src/Html.php by phpmd

          ShortMethodName

          Since: 0.2

          Detects when very short method names are used.

          Example

          class ShortMethod {
              public function a( $index ) { // Violation
              }
          }

          Source https://phpmd.org/rules/naming.html#shortmethodname

          Avoid using short method names like Html::li(). The configured minimum method name length is 3.
          Open

              public static function li(mixed ...$arguments): self
              {
                  array_unshift($arguments, 'li');
          
                  return self::createElement(...$arguments);
          Severity: Minor
          Found in src/Html.php by phpmd

          ShortMethodName

          Since: 0.2

          Detects when very short method names are used.

          Example

          class ShortMethod {
              public function a( $index ) { // Violation
              }
          }

          Source https://phpmd.org/rules/naming.html#shortmethodname

          Severity
          Category
          Status
          Source
          Language